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 a开发者_C百科nd view.
Thx!
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.
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
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.
精彩评论