If there is one thing we can all agree on, say it with me…ruby doesn’t have enough settings solutions. You finished the sentence without even reading it didn’t you?
Actually considering there are a million settings solutions, this is probably the last thing we need. That being said, I decided to add my own personal settings solution to the mix called Settingslogic. It’s nothing crazy or new. Just a simple solution to a simple problem. Settingslogic provides globally accessible settings via an ERB enabled YAML file. It has been great for my apps, maybe you will enjoy it too. Here’s how it works…
This is a typical YAML file, notice ERB is allowed.
# app/config/application.yml defaults: &defaults cool: saweet: nested settings neat_setting: 24 awesome_setting: <%= "Did you know 5 + 5 = " + (5 + 5) + "?" %> development: <<: *defaults neat_setting: 800 test: <<: *defaults production: <<: *defaults
>> RAILS_ENV => "development" >> Settings.cool => "#<Settingslogic::Settings ... >" >> Settings.cool.saweet => "nested settings" >> Settings.neat_setting => 800 >> Settings.awesome_setting => "Did you know 5 + 5 = 10?"
You got it!
Wow! Thank you!
I always wanted to write in my site something like that. Can I take part of your post to my blog?
Of course, I will add backlink?
Regards, Your Reader