You can do this already with code like this:

  

wepay_config = ActiveSupport::OrderedOptions.new  
wepay_config.use_stage = false  
  
Rails.application.config.wepay = wepay_config  

  

Accessed through Rails.application.config.wepay.use_stage

  

This is how the Railties (like Active Support) do it and so I think this is
how you should do it too.

  

> On Dec 30 2015, at 2:25 pm, Ben Nelson <[email protected]> wrote:  

>

> When I am writing a Rails application it kind of makes sense to have custom
configuration options. In Rails 4.2.5 I tried to add these to a config file in
the config directory for the environment that gets loaded but I get an error:  
  
  
/Users/bytenel/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.2.5/lib/rails/railtie
/configuration.rb:95:in `method_missing': undefined method `wepay' for
#<Rails::Application::Configuration:0x007fde51d21450> (NoMethodError)  
  
  
Since I am trying to use my configuration like so:  
  
  
Rails.configuration.wepay.client_id  
or alternatively  
Rails.application.webpay.client_id  
  
  
It would be nice to do this since it has a good ring to it semantically for my
configuration variables and makes sense to the location of it (I can easily
check my Rails config file for the environment to check the loading).  
  
Such a configuration would look like this:

>

>  
Rails.application.configure do  
  config.wepay.use_stage = false  
  config.wepay.client_id = 'your_client_id'  
  config.wepay.client_secret = 'your_client_secret'  
end

>

>  

>

> Rather than using the generic

>

>  

>

> Rails.application.configure do

>

>  config.x.wepay.use_stage

>

> end

>

>  

>

> Or some such.

>

>  

>

> What does the team think?  
  

>

> \--  
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.  
To unsubscribe from this group and stop receiving emails from it, send an
email to [[email protected]](mailto:rubyonrails-
[email protected]).  
To post to this group, send email to [rubyonrails-
[email protected]](mailto:[email protected]).  
Visit this group at <https://groups.google.com/group/rubyonrails-core>.  
For more options, visit <https://groups.google.com/d/optout>.  

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to