Hello,
I am having a problem using a Struct in one of my controllers.  My  
code works fine in a standalone Ruby program and in IRB but fails in  
Rails.
Here''s the code:
   Result = Struct.new :status, :detail, :url
   r = Result.new ''OK'', ''Top banana'',
''http://blah''
When that''s executed in one of my actions, Rails give me this:
SyntaxError (/path/to/app/config/../app/controllers/ 
store_controller.rb:79: dynamic constant assignment
       Result = Struct.new(:status, :detail, :url)
               ^):
[rest of trace snipped]
Any guidance would be much appreciated.
Thanks and regards,
Andy Stewart
--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---
Try putting Result = Struct.new(:status, :detail, :url) outside your action and directly in the controller class, so it''s scope is StoreController::Result Vish On 11/11/06, Andrew Stewart <boss-rAnrN1QAkGGttCpgsWEBFlaTQe2KTcn/@public.gmane.org> wrote:> > Hello, > > I am having a problem using a Struct in one of my controllers. My > code works fine in a standalone Ruby program and in IRB but fails in > Rails. > > Here''s the code: > > Result = Struct.new :status, :detail, :url > r = Result.new ''OK'', ''Top banana'', ''http://blah'' > > When that''s executed in one of my actions, Rails give me this: > > SyntaxError (/path/to/app/config/../app/controllers/ > store_controller.rb:79: dynamic constant assignment > Result = Struct.new(:status, :detail, :url) > ^): > [rest of trace snipped] > > Any guidance would be much appreciated. > > Thanks and regards, > Andy Stewart > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Try putting Result = Struct.new(:status, :detail, :url) outside your > action and directly in the controller class, so it''s scope is > StoreController::Result > > VishThat fixed it. I see the problem now. Thank you very much! Andy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---