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

**URL:** <https://www.ruby-forum.com/t/my-own-plugin-how-where-to-place-configuration-params/120647>\
**Category:** Rails\
**Created:** [November 19, 2007, 3:10pm UTC](https://www.ruby-forum.com/t/my-own-plugin-how-where-to-place-configuration-params/120647 "2007-11-19T15:10:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [November 19, 2007, 3:10pm UTC](https://www.ruby-forum.com/t/my-own-plugin-how-where-to-place-configuration-params/120647/1 "2007-11-19T15:10:03Z")

</div>

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:

# environment.rb

MyVeryCoolPlugin.some\_value = “yeah!”  
MyVeryCoolPlugin.some\_other\_value = “noooo!”

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

Thanks for help  
Josh

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [November 23, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/my-own-plugin-how-where-to-place-configuration-params/120647/2 "2007-11-23T16:31:53Z")

</div>

Hi,

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.

regards,

Javier
