I have a Rails site that needs to have global access to some settings which I would like to set in a separate file, e.g. the location of a companion server. I have done this in a couple of ways but none of them seems to be very elegant or Ruby-like. Does anyone have any input on the best practice of dealing with data of this kind. Thanks in advance Erik Lindblad --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Erik Lindblad wrote:> I have a Rails site that needs to have global access to some settings > which I would like to set in a separate file, e.g. the location of a > companion server. I have done this in a couple of ways but none of > them seems to be very elegant or Ruby-like. Does anyone have any input > on the best practice of dealing with data of this kind. > > Thanks in advance > > Erik Lindbladenvironment.rb -- 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 -~----------~----~----~----~------~----~------~--~---
Thank you for the suggestion. I tried environment.rb but I think it is not a nice solution because of the discrepancy in data types. The settings in environment.rb is mostly directives on hov the server should act and updates require restarting the server. What I would like is a separate file for settings regarding the application itself, not the server on which it is run. A trivial difference perhaps, but I think it is an important one. I don''t like setting the preferred graphics format for user uploads in the same place as where I set e.g. which parts of Rails to use. I will use this solution if there are no good alternatives but I have a feeling there are. Regards Erik On 24 Okt, 12:55, Mikkel Bruun <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Erik Lindblad wrote: > > I have a Rails site that needs to have global access to some settings > > which I would like to set in a separate file, e.g. the location of a > > companion server. I have done this in a couple of ways but none of > > them seems to be very elegant or Ruby-like. Does anyone have any input > > on the best practice of dealing with data of this kind. > > > Thanks in advance > > > Erik Lindblad > > environment.rb > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
igorkasyanchuk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Oct-24 11:59 UTC
Re: Best practice on global settings
I create a module in lib folder with some text constants. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi This sounds interesting. Could you give a more detailed example. Do you use module variables or module instance variables, where do you include it and so on. Do you know of any articles on this subject. I would be very thankful for the assistance. Kindest regards Erik On 24 Okt, 13:59, "igorkasyanc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <igorkasyanc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I create a module in lib folder with some text constants.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi This sounds interesting. Could you give a more detailed example. Do you use module variables or module instance variables, where do you include it and so on. Do you know of any articles on this subject. I would be very thankful for the assistance. Kindest regards Erik On 24 Okt, 13:59, "igorkasyanc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <igorkasyanc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I create a module in lib folder with some text constants.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Oct 24, 5:14 am, Erik Lindblad <e...-gTO0lQh45js@public.gmane.org> wrote:> Hi > > This sounds interesting. Could you give a more detailed example. Do > you use module variables or module instance variables, where do you > include it and so on. Do you know of any articles on this subject. I > would be very thankful for the assistance. > > Kindest regards > > Erik > > On 24 Okt, 13:59, "igorkasyanc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" > > <igorkasyanc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I create a module in lib folder with some text constants.some time ago, somebody suggested searching ageilwebdev.com on "settings", it works: http://agilewebdevelopment.com/plugins/search?search=settings --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
igorkasyanchuk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Oct-24 13:14 UTC
Re: Best practice on global settings
lib\somefile.rb module MySettingsContainer SOMETEXT = "SOME TEXT VALUE" end controller requere "somefile.rb" (or require lib/somefile.rb) class AAA < AplicationController include MySettingsContainer # i think it''s not needed def index @result = MySettingsContainer::SOMETEXT end end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Many thanks, I will try that. /Erik On 24 Okt, 15:14, "igorkasyanc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <igorkasyanc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> lib\somefile.rb > > module MySettingsContainer > SOMETEXT = "SOME TEXT VALUE" > end > > controller > > requere "somefile.rb" (or require lib/somefile.rb) > > class AAA < AplicationController > include MySettingsContainer # i think it''s not needed > > def index > @result = MySettingsContainer::SOMETEXT > end > > end--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Wed, 24 Oct 2007 04:03:54 -0700, Erik Lindblad wrote:> Thank you for the suggestion. I tried environment.rb but I think it is > not a nice solution because of the discrepancy in data types. The > settings in environment.rb is mostly directives on hov the server > should act and updates require restarting the server. What I would > like is a separate file for settings regarding the application itself, > not the server on which it is run.How about: - Use the app_config plugin to get a nice syntax - Add a line in config/environment.rb to ''require application'' - Put the app_config stuff in config/application.rb I think that''ll work, unless ''require application'' ends up loading one of the other application.rb files due to load path order, in which case you should be able to do something like require "#{config_dir}/application". -- Jay Levitt | Boston, MA | My character doesn''t like it when they Faster: jay at jay dot fm | cry or shout or hit. http://www.jay.fm | - Kristoffer --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---