My own plugin: how/where to place configuration params?

Hi all

I’m creating my own plugin that I want to use in different projects. And
because my different projects need different configurations of the
plugin I’d like to provide an easy way to configure them, maybe
something like the following:


MyVeryCoolPlugin.some_value = “yeah!”
MyVeryCoolPlugin.some_other_value = “noooo!”

Does Rails provide something like that? Or how can I achieve this?

Thanks for help


you can achieve that by defining a module in your plugin lib directory
and then defining mattr_accessors for your configuration values. With
that, you are really defining class_level variables (so they will
persist during the whole application life) and the corresponding
accessors for getting and setting them.

Actually that’s my favourite way of defining configuration variables for
my plugins, since you can easily provide default values and at the same
time anyone using the plugin has a place where to look for the available
configuration options.