-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Feb 28, 2006, at 1:10 PM, Xavier Noria wrote:> I''d need to be able to figure out the filename of the SQLite
> backend of this application (for backups).
>
> Does Rails provide API to access the database configuration? Or do
> I need to load db/database.yml and check for ENV["RAILS_ENV"]? A
> simple inspection of the ActiveRecord::Base.connection object sheds
> no light, the @filename attribute is there but instance_methods
> returns no reader that seems relevant.
class ActiveRecord::Base
def self.connection_specification
@@defined_connections[name].config rescue nil
end
end
ActiveRecord::Base.connection_specification[:database]
This may break between Rails releases since the connection
specification code has been in flux. Preferably, we''d be able to say
Foo.connection.spec or similar. Please create an enhancement request
(or a patch!) at http://dev.rubyonrails.org if you''d like to pursue a
better API.
Best,
jeremy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (Darwin)
iD8DBQFEBMISAQHALep9HFYRArX1AJsEl+S++79WdToNMb5Ys1FRIqP+UQCggVqx
nbHeZ7WByJgxVPAoKbccqe4=ATZo
-----END PGP SIGNATURE-----