Thursday, 6 November 2008

Getting the Database name in Merb and DataMapper

After a lot of searching and banging my head against my keyboard I finally found how to get the database name for my Merb application:
Macintosh:ruby-rss-feeds marktucks$ merb -i
>> repository(:default).adapter
=> #, @name=:default, @transactions={}>
>> repository(:default).adapter.uri
=> #
>> repository(:default).adapter.uri.path
=> "sample_development.db" # YAY!

I'm sure there must be a better way to do this. A Rails::Configuration.database_configuration equivalent? But I just cannot find it. The
doesn't seem to have a database property / method. You can get stuff like the host (

Any suggestions / better solutions are welcome.

1 comment:

afcool83 said...

nope, that's the proper way to do it