views:

34

answers:

3

When coding with PHP I always separate configuration values like perPage value in a separated ini file. How are you Ruby masters do this with Rails?

I would like to access config values inside my model, controller and view.

Thx!

+1  A: 

Not sure about masters :) but mortal developers can usually leverage some of the existing plugins like this one: http://www.workingwithrails.com/railsplugin/5324-app-config

There are actually quite a few of them, so you'll probably find something that will suit you.

neutrino
+2  A: 

I've generally just used a plugin like http://github.com/cjbottaro/app_config or wrote my own. I like using a config.yml file in the config directory.

Ben
If you prefer not to use a plugin, you can easily read YAML files in Ruby. The convention is to put these files in the `config` dir.
Jonathan Julian
+1  A: 

There isn't really anything built in to rails to do this, but luckily there's a great plugin called settingslogic which lets you externalise your settings.

Having said that I personally like to make these things constants in my model, so for example I'd have something like this:

class Person < AR:B
  DEFAULT_PER_PAGE = 10
end
jonnii