views:

16

answers:

1

Since Rails is using Ruby (dynamic language), would it be possible to create a very flexible 'configuration' class that has properties that you use throughout the website, AND have the ability to add new class properties (in the db for web modification) and then just use it in the code.

Each property would be of a specific type like a string, integer, bool etc.

You can't do this in a strongly typed language, but it must be possible with Ruby!

So say my class is like:

globalConfig.is_active

globalConfig.admin_email

I guess to make this work, I would loop through all the properties in the db, create properties in the class and assign the value right?

+1  A: 

I actually have a settings plugin on GitHub you can use:

http://github.com/bellmyer/settings

It makes this easier for you. Right now it's not rails3-ready, so let me know if you need that. I also need to put in the time to roll it into a gem, instead of a plugin.

If you end up using it, let me know and I'll get it up to date. Otherwise, you can look at the code to see how I did things, and use that to help build your own custom solution.

Jaime Bellmyer