Class: Nitra::RailsTooling
- Inherits:
-
Object
- Object
- Nitra::RailsTooling
- Defined in:
- lib/nitra/rails_tooling.rb
Class Method Summary collapse
-
.connect_to_database ⇒ Object
Find the database config for the current TEST_ENV_NUMBER and manually initialise a connection.
- .reset_cache ⇒ Object
Class Method Details
.connect_to_database ⇒ Object
Find the database config for the current TEST_ENV_NUMBER and manually initialise a connection.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/nitra/rails_tooling.rb', line 6 def self.connect_to_database return unless defined?(Rails) # Config files are read at load time. Since we load rails in one env then # change some flags to get different environments through forking we need # always reload our database config... ActiveRecord::Base.configurations = YAML.load(ERB.new(IO.read("#{Rails.root}/config/database.yml")).result) ActiveRecord::Base.clear_all_connections! ActiveRecord::Base.establish_connection end |
.reset_cache ⇒ Object
17 18 19 20 |
# File 'lib/nitra/rails_tooling.rb', line 17 def self.reset_cache return unless defined?(Rails) Rails.cache.reset if Rails.cache.respond_to?(:reset) end |