I have some constants defined in my application_helper.rb and I keep getting these warning: already initialzed constant ________ I greped my project and made sure these constants are not defined or set elsewhere. is my application_helper being loaded multiple times? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You should check if it''s defined using defined?. For example, you''ll see something like this in your environment.rb: RAILS_GEM_VERSION = ''1.2.6'' unless defined? RAILS_GEM_VERSION On Jan 10, 11:16 pm, rubynuby <dear...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have some constants defined in my application_helper.rb and I keep > getting these warning: already initialzed constant ________ > > I greped my project and made sure these constants are not defined or > set elsewhere. is my application_helper being loaded multiple times?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
thanks, that got rid of the warnings. still it suggests my application_helper.rb is being loaded multiple times per request. is that normal? doesn''t seem efficient. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Not multiple times per request, but rather reloaded per request. The first request may be fine, but subsequent requests will show that error. A constant is exactly that: a constant variable for the life of your application. If you''re defining constants in your application_helper, maybe you should be doing it somewhere else? On Jan 11, 2008 9:52 AM, rubynuby <dearluu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > thanks, that got rid of the warnings. > > still it suggests my application_helper.rb is being loaded multiple > times per request. is that normal? doesn''t seem efficient. > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 Jan 11, 2008, at 12:22 AM, rubynuby wrote:> still it suggests my application_helper.rb is being loaded multiple > times per request. is that normal? doesn''t seem efficient.No, no, you shouldn''t be throwing any defined? like that. One uses defined? when it makes sense in her context, not to hide a suspicious behaviour. What you are seeing is something that shouldn''t happen, so the right thing to do is to discover why it is happening and fix it. I think a trick to debug that could be to throw RAILS_DEFAULT_LOGGER.debug(caller.join("\n")) if defined? SOME_CONSTANT SOME_CONSTANT = value in the helper module. There we use defined? to print the execution stack just in the second run. -- fxn --~--~---------~--~----~------------~-------~--~----~ 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 Jan 11, 2008, at 12:26 AM, Ryan Bigg wrote:> Not multiple times per request, but rather reloaded per request. The > first request may be fine, but subsequent requests will show that > error. A constant is exactly that: a constant variable for the life > of your application. If you''re defining constants in your > application_helper, maybe you should be doing it somewhere else?But this is not the case with application_helper.rb, in the sense that ApplicationHelper is autoloaded: $ script/console Loading development environment (Rails 2.0.2) >> Dependencies.autoloaded? ApplicationHelper => true That is a side-effect of prepare_application. So, you know, you get a fresh new module in the fresh new constant ApplicationHelper per request in development mode. Any nested constant is new in consequence, hence if everything is set up as usual you don''t get those warnings. -- fxn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---