Max Williams wrote:
Hi Hemant
I found the problem - the code you gave me doesn't work with the config,
because having a colon at the start of the variable names, like this
:development:
:backgroundrb:
:port: 11006
:environment: development
:persistent_delay: 2
This means that the keys in the config hash that is built up all start
with a colon and are interpreted as symbols rather than strings. So, i
end up with a hash that looks like this:
config = {:development => {:backgroundrb => {:port => 11006, etc}}
{:staging => {:backgroundrb => etc etc
BUT, the environment variable, set with -e, is a regular string. So, if
i start backgroundrb with "-e staging", it tries to match "staging"
against :staging, doesn't find a match, and so goes with the defaults.
I fixed this in mine by converting the environment variable to a symbol
before comparing with the config hash: here's my altered version of the
code you gave me in the earlier post:
if config[environment.to_sym]
deep_proc = Proc.new do |key, oldval, newval|
if oldval.kind_of?(Hash) && newval.kind_of?(Hash)
next oldval.merge(newval,&deep_proc)
end
next newval
end
config.merge!( config[environment.to_sym], &deep_proc)
end
Thanks
max
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---