Skip to content

Commit

Permalink
Merge git://github.com/tyler/db-charmer
Browse files Browse the repository at this point in the history
  • Loading branch information
kovyrin committed Apr 9, 2010
2 parents 62c2889 + fb08db1 commit b124b20
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/db_charmer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ module DbCharmer
@@connections_should_exist = true
mattr_accessor :connections_should_exist

@@env = defined?(RAILS_ENV) ? RAILS_ENV : 'development'
mattr_accessor :env

def self.connections_should_exist?
!! connections_should_exist
end
Expand Down
4 changes: 2 additions & 2 deletions lib/db_charmer/active_record_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module ClassMethods

def establish_real_connection_if_exists(name, should_exist = false)
name = name.to_s
config = configurations[RAILS_ENV][name]
config = configurations[DbCharmer.env][name]
unless config
if should_exist
raise ArgumentError, "Invalid connection name (does not exist in database.yml): #{RAILS_ENV}/#{name}"
raise ArgumentError, "Invalid connection name (does not exist in database.yml): #{DbCharmer.env}/#{name}"
end
return # No need to establish connection - they do not want us to
end
Expand Down

0 comments on commit b124b20

Please sign in to comment.