Joshua Muheim
2007-Nov-19 14:10 UTC
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: # 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
javier ramirez
2007-Nov-23 15:30 UTC
Re: My own plugin: how/where to place configuration params?
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---