views:

17

answers:

1

Hi

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

A: 

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)
Nikita Rybak
And does my application re-read this property when changed, or do I have to restart the server?
Neigaard
@Neigaard It'll take you exactly 2 minutes to try and see.
Nikita Rybak
Hm point taken... It does not reload the properties
Neigaard