config file in schedule.rb with Rails Whenever gem?
Posted
by yuval
on Stack Overflow
See other posts from Stack Overflow
or by yuval
Published on 2010-03-28T21:24:28Z
Indexed on
2010/03/29
9:33 UTC
Read the original article
Hit count: 580
I have a file called config.yml in my /config folder of my rails application. I also have an initializer: config/initializers/load_config.rb with the following code:
APP_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/config.yml")
I am using the Whenever gem to set up a cron job, and would like to use my APP_CONFIG to call a function like so:
#inside schedule.rb
every 2.hours do
runner "MyModel.someMethod('#{APP_CONFIG['some_value']}')"
end
but the Whenever gem doesn't seem to recognize the config file when I call
whenever --update-crontab mysite
How can I incorporate values from my configuration in my schedule.rb file (instead of hard-coding the value)?
Thanks!
© Stack Overflow or respective owner