diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb index 2340abd4..2c3c0df1 100755 --- a/app/controllers/api/api_controller.rb +++ b/app/controllers/api/api_controller.rb @@ -41,6 +41,21 @@ class Api::ApiController < ActionController::API end end + def website_connection(license) + default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase, + :username => license.dbusername, :password => license.dbpassword) + + end + + def reconnect_default_db + ActiveRecord::Base.establish_connection(Rails.env) + end + + # Regular database.yml configuration hash + def default_connection + @default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup + end + def cache_license(url, lookup) @license = License.new(url, lookup)