Michael Johnston
2007-Apr-04 16:24 UTC
indentifier needs to be constant error when calling Struct.new
In my current rails application, I now have the following issue: script/console Loading development environment. >> bob = Struct.new(:anysymbol) NameError: identifier anysymbol needs to be constant from (irb):1:in `new'' from (irb):1 >> exit This occurs regardless of what symbols are passed to Struct.new call. Consequently, nothing that uses Struct will work anymore. I discovered this when attempting to use Fastercsv, which fails when required. I''m completely mystified by this error and have little idea how to go about tracking down what is causing it, short of rebuilding my application one step at a time. It''s fairly big to be doing with at this point. What could cause such a problem? I''ve made no monkeypatches to Struct. I can''t find any code messing with Struct among the plugins I''ve installed. Help. Michael Johnston --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Michael Johnston
2007-Apr-04 16:55 UTC
Re: indentifier needs to be constant error when calling Struct.new
whew. I managed to discover this relatively quickly once I quelled my panic. It was caused by an extension called acts_as_wizard, which monkeypatches Symbol thusly: class Symbol ...some other monkeycrap^H^H^H^Hpatching def to_str id2name end end I''m not entirely sure how this ends up breaking Struct.new, but it does. It''s a lame patch anyway, he should just use id2name or "# {mysymbol}" instead of making such a patch. Coercions and other such things that are likely to be pervasively used outside of the code you are writing are bad bad targets for monkeypatching. Since the time I installed acts_as_wizard, I have stopped using it and written my own wizard management code, so luckily I can easily just pitch this plugin. Michael Johnston On 4-Apr-07, at 9:24 AM, Michael Johnston wrote:> > In my current rails application, I now have the following issue: > > script/console > Loading development environment. >>> bob = Struct.new(:anysymbol) > NameError: identifier anysymbol needs to be constant > from (irb):1:in `new'' > from (irb):1 >>> exit > > > This occurs regardless of what symbols are passed to Struct.new call. > > Consequently, nothing that uses Struct will work anymore. I > discovered this when attempting to use Fastercsv, which fails when > required. > > > > I''m completely mystified by this error and have little idea how to go > about tracking down what is causing it, short of rebuilding my > application one step at a time. It''s fairly big to be doing with at > this point. > > What could cause such a problem? > > I''ve made no monkeypatches to Struct. I can''t find any code messing > with Struct among the plugins I''ve installed. > > > Help. > > Michael Johnston > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Pekka Paal
2007-Nov-20 12:17 UTC
Re: indentifier needs to be constant error when calling Stru
Hey thanks for this info, I''ve been having the same problems with net/sftp and net/imap and could not figure out the reason, turned out to be the act_as_wizard plugin! Michael Johnston wrote:> whew. I managed to discover this relatively quickly once I quelled my > panic. > > It was caused by an extension called acts_as_wizard, which > monkeypatches Symbol thusly: > > class Symbol > ...some other monkeycrap^H^H^H^Hpatching > def to_str > id2name > end > end > > I''m not entirely sure how this ends up breaking Struct.new, but it > does. It''s a lame patch anyway, he should just use id2name or "# > {mysymbol}" instead of making such a patch. Coercions and other such > things that are likely to be pervasively used outside of the code you > are writing are bad bad targets for monkeypatching. > > Since the time I installed acts_as_wizard, I have stopped using it > and written my own wizard management code, so luckily I can easily > just pitch this plugin. > > Michael Johnston-- 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 -~----------~----~----~----~------~----~------~--~---