[Rails] Getting database config info
Robbie Carlton
robbie.carlton at gmail.com
Wed Feb 1 14:53:58 GMT 2006
Hi folks. I have a very small problem which is probably very simple. But
I've scoured the api and the rails book with no luck.
I'm trying to get information about the database definition out of active
record. When I go into console and say
ActiveRecord::Base.connection
I get a MysqlAdapter object, with an instance variable called @config that's
a hash containing all the information I need. However I can't get at the
config variable. I can think of two solutions, neither of which is entirely
satisfactory. Either extend the definition of MysqlAdapter to include an
accessor for database name, but I'm loathe to do this as it's hacky and will
cause problems with switching to different database types and updates to
rails. The other is to parse the config file myself, but again this is
clearly not clever as it's duplication.
Thanks in advance
Robbie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060201/d882e470/attachment.html
More information about the Rails
mailing list