Forum: Ruby on Rails [NEWB] How to access database.yml parameters in a controller

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F16def8015a7562a285c65a14be48540?d=identicon&s=25 Mathieu Chappuis (Guest)
on 2005-12-22 16:27
(Received via mailing list)
Hi,

Are the active database.yaml attributes for the current environment
(dev, prod, test) available inside a controler ?

adapter, host, db, socks, etc.

AFIK Class#connection don't give back theses infos.

Thanks
67b6389be42524fbd776e44fd35c3d7e?d=identicon&s=25 Peter Donald (Guest)
on 2005-12-22 22:51
(Received via mailing list)
On 12/23/05, Mathieu Chappuis <mathieu.chappuis.lists@gmail.com> wrote:
> Are the active database.yaml attributes for the current environment
> (dev, prod, test) available inside a controler ?

ActiveRecord::Base.configurations[RAILS_ENV.to_sym]['database']
ActiveRecord::Base.configurations[RAILS_ENV.to_sym]['host']
ActiveRecord::Base.configurations[RAILS_ENV.to_sym]['adapter']

--
Cheers,

Peter Donald

Blog: http://www.RealityForge.org
This topic is locked and can not be replied to.