I am new to rails, and I have no idea how to make properties in a settings file that I can read from my rails application. I have this code:
Time.now.advance(:days => -7)
I would like it to be configurable, so that I can configure it to be (:months => -2) or what ever I like. How do I do this in rails?
Thank you
Set this hash in one of your configuration files (in config/environments/development.rb
or config/environment.rb
, for example):
ADVANCE_SPAN = {:days => -7}
And then use it in your code
Time.now.advance(ADVANCE_SPAN)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.