Jarmark.org » AppConfig

Jarmark.org » AppConfig: If you’ve got a RAILS configuration on your hands, give AppConfig a shot to store all of your local configuration requirements. It integrates seamlessly with the master rails configuration files (environment.rb). You can install it by just running:

script/plugin install http://svn.jarmark.org/rails/app_config

Unfortunately, the actual Parameter names are NOT Unicode safe, that is to say, only A-Z, a-z and 0-9 can be used as the Parameter name, but parameter values are unicode safe, so they’ll work just fine for those chinese characters of yours… Just don’t go trying:

logger.error( AppConfig.汉子 ) logger.error( AppConfig[:汉子] ) logger.error( AppConfig.param(‘汉子‘) ) logger.error( AppConfig.param(:汉子) )

As none of those will work 🙂 Fortunately, the output of these will work just fine.

(In config/environment.rb)

Rails::Initializer.run do |config| # My Killer App Specific Settings… config.app_config.MY_PARAM = ‘在这里用UTF-8是很方便!‘ end

(In your app/controller/some_controller.rb)

logger.error( AppConfig. MY_PARAM) logger.error( AppConfig[:MY_PARAM] ) logger.error( AppConfig.param(‘MY_PARAM’) ) logger.error( AppConfig.param(:MY_PARAM) )

By the way, don’t forget to set: KCODE=’UTF8′ inside of your config/environment.rb… Otherwise, you’re unicode will be all messed up.

Leave a Reply

Your email address will not be published. Required fields are marked *