Rails 3: is there a way to set gem configuration options in environment.rb instead of foo.yml?

My rails application uses a gem, which requires some configuration parameters specified in the foo.yml file:

development:
  username: MyDevUserName
  password: MyDevPassword
production:
  username: MyPRODUserName
  password: MyPRODPassword

I do not want a password in my source code and want to do something like:

development:
  username: <%= ENV['THE_USERNAME'] %>
  password: <%= ENV['THE_PASSWORD'] %>
production:
  username: <%= ENV['THE_USERNAME'] %>
  password: <%= ENV['THE_PASSWORD'] %>

However, for some reason, <% = ENV ['XXX']%> works in my Settings.yml file, but does not work in my foo.yml file (I assume the foo gem load .yml file does not allow interpretation).

So...

I am wondering if Ruby / Rails has a universal way to specify variables in environment.rb instead of foo.yml?

For example, can I have an empty foo.yml file and add the following to environment.rb :

Foo::_something_._somethingelse =
{
  :username => ENV['THE_USERNAME'],
  :password => ENV['THE_PASSWORD']
}
+3
1

EDIT: Heroku...

- . ENV , Heroku vars, , . (, )... CONFIG VARS. . Heroku Dev , Heroku, .

: , ()

environment.rb, .

- foo.yml (, git .gitignore). , , , , . , .

capistrano , , [app]/shared/config/foo.yml, softlink [sharedpath] [ ]. capistrano :

task :after_update_code do
  run "ln -s #{shared_path}/config/foo.yml #{release_path}/config/foo.yml"
end
+3

All Articles