Hi, I''m trying to externalize the strings in my application, and have this in the environment.rb file APP_TEXT (HashWithIndifferentAccess).new(YAML::load(File.open("#{RAILS_ROOT}/config/strings.yml"))), This works fine until I try to do the functional and unit tests, where I get an uninitialized constant HashWithIndifferentAccess (NameError). I''ve tried it with Hash.HashWithIndifferentAccess, Hash:HashWithIndifferentAccess, and Hash::HashWithIndifferentAccess and none of these work. Am I supposed to be including something somewhere inside of the tests? -- 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 -~----------~----~----~----~------~----~------~--~---
Hi, Do you put this line APP_TEXT = ... at the end or beginning of the environment.rb file? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
First I put it right below require File.join(File.dirname(__FILE__), ''boot'') and then I tried moving it to Rails::Initializer.run do |config| APP_TEXT = (HashWithIndifferentAccess).new(YAML::load(File.open("#{RAILS_ROOT}/config/strings.yml"))) however this does not work. reHa wrote:> Hi, > > Do you put this line APP_TEXT = ... > at the end or beginning of the environment.rb file?-- 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 -~----------~----~----~----~------~----~------~--~---
I ussually add my things after the initializer - mybe try this way Rails::Initializer.run do |config| #standard stuff end #my stuff APP_TEXT = .... On 29 Paź, 20:43, Daniel Fac <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> First I put it right below > require File.join(File.dirname(__FILE__), ''boot'') > and then I tried moving it to > Rails::Initializer.run do |config| > APP_TEXT > (HashWithIndifferentAccess).new(YAML::load(File.open("#{RAILS_ROOT}/config/strings.yml"))) > however this does not work. > > reHa wrote: > > Hi, > > > Do you put this line APP_TEXT = ... > > at the end or beginning of the environment.rb file? > > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Oct 29, 7:46 pm, reHa <pres...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I ussually add my things after the initializer - mybe try this way > > Rails::Initializer.run do |config| > #standard stuff > end > > #my stuff > APP_TEXT = .... >The reason why this is a good thing is that it means the code runs after Rails has been loaded. Given that HashWithIndifferentAccess is part of rails this is a good thing ! Fred (PS: config/initializers) --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks! that worked perfectly, I still don''t really understand why the error didn''t come up during development and only during the unit testing. But thanks a lot! Frederick Cheung wrote:> On Oct 29, 7:46�pm, reHa <pres...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> I ussually add my things after the initializer - mybe try this way >> >> Rails::Initializer.run do |config| >> � #standard stuff >> end >> >> #my stuff >> APP_TEXT = .... >> > > The reason why this is a good thing is that it means the code runs > after Rails has been loaded. Given that HashWithIndifferentAccess is > part of rails this is a good thing ! > > Fred > (PS: config/initializers)-- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
No problem - actually it is interisting question why it worked on the development environment but I don''t know the answer ;) On 29 Paź, 21:00, Daniel Fac <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Thanks! that worked perfectly, > I still don''t really understand why the error didn''t come up during > development and only during the unit testing. But thanks a lot! > > > > Frederick Cheung wrote: > > On Oct 29, 7:46 pm, reHa <pres...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> I ussually add my things after the initializer - mybe try this way > > >> Rails::Initializer.run do |config| > >> #standard stuff > >> end > > >> #my stuff > >> APP_TEXT = .... > > > The reason why this is a good thing is that it means the code runs > > after Rails has been loaded. Given that HashWithIndifferentAccess is > > part of rails this is a good thing ! > > > Fred > > (PS: config/initializers) > > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---