Alex Rivera | Logout

Displaying host and database names in Rails

Asked 2008-11-06T00:01:56.693
56

I want to display the current host and database names in a view.

Where can I get these names?

Are there some predefined environment or global variables?

Edit
Report

1 Answer

17

On Rails 3, this is most easily accessed via Rails::Application.config, like so:

    YourApplicationClassName::Application.config.database_configuration[::Rails.env]

If you try to call it directly on Rails instead of YourApplicationClassName, rails will give you a deperecation warning. If you don't know what your application constant is, try Rails.application.class.name in a Rails console for your app.

answered 2011-08-05T08:03:18.480

Your Answer