Skip to content

Instantly share code, notes, and snippets.

@ilake
Last active June 8, 2016 02:15
Show Gist options
  • Save ilake/fc68aee49aec15a4e2865a635863bb26 to your computer and use it in GitHub Desktop.
Save ilake/fc68aee49aec15a4e2865a635863bb26 to your computer and use it in GitHub Desktop.
> Rails.application.config_for(:database)
=> {"adapter"=>"mysql2", "encoding"=>"utf8", "reconnect"=>false, "database"=>"listia_development", "pool"=>5, "username"=>"listia", "socket"=>"/tmp/mysql.sock"}
> h = Hashie::Mash.new(Rails.application.config_for(:database))
=> #<Hashie::Mash adapter="mysql2" database="listia_development" encoding="utf8" pool=5 reconnect=false socket="/tmp/mysql.sock" username="listia">
> h.adapter
=> "mysql2"
> h.database
=> "listia_development"
class Application < Rails::Application
config.x.foo = Hashie::Mash.new(Rails.application.config_for(:bar))
...
# Then you could use Rails.configuration.x.foo.yyy to access the config value of current environment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment