Skip to content

Instantly share code, notes, and snippets.

@bayleedev
Forked from dhh/config_for.rb
Created September 23, 2015 18:27

Revisions

  1. @dhh dhh created this gist Jul 6, 2014.
    21 changes: 21 additions & 0 deletions config_for.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    module YourApp
    class Application < Rails::Application
    # Convenience for loading config/foo.yml for the current Rails env.
    #
    # Example:
    #
    # config/cleversafe.yml:
    #
    # production:
    # url: http://127.0.0.1:8080
    # namespace: bc3_production
    # development:
    # url: http://bc3.dev/cleversafe
    # namespace: bc3_development
    #
    # Cleversafe.config = Application.config_for :cleversafe
    def config_for(name, env = Rails.env)
    YAML.load_file(Rails.root.join("config/#{name}.yml"))[env]
    end
    end
    end