Hi all , I am new to Ruby on Rails.. I have a requirement to handle the has_many functionality in helper itself. I have created the active_record object to the model dynamically. From the object I have tried to access the has_many functionality followed by destroy_all function. I have posted my code and error which I received from my code . Please help me.... Thanks in advance... Attachments: http://www.ruby-forum.com/attachment/6437/rec.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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jul 20, 12:42 am, abinila shanthi <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi all , > > I am new to Ruby on Rails.. > I have a requirement to handle the has_many functionality in > helper itself. I have created the active_record object to the model > dynamically. From the object I have tried to access the has_many > functionality followed by destroy_all function. > > I have posted my code and error which I received from my code . Please > help me.... >I''d love to, but this code is just about beyond help. Why on EARTH are you doing this? In any case, at least part of your problem is that the Class object created by get_active_record doesn''t wind up with a *name*, which is confusing the association code (it''s trying to generate the name of the foreign key for the has_many). Try assigning the class to a constant to sort that out. As for the rest of the code, nearly *any* structure one could devise would be clearer than this. If you''re using AR but not Rails, the *least* you could do would be to split out the model definitions into files and ''require'' them in all at the top... --Matt Jones -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Matt Jones wrote in post #1011855:> On Jul 20, 12:42am, abinila shanthi <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> > I''d love to, but this code is just about beyond help. Why on EARTH are > you doing this? > > In any case, at least part of your problem is that the Class object > created by get_active_record doesn''t wind up with a *name*, which is > confusing the association code (it''s trying to generate the name of > the foreign key for the has_many). Try assigning the class to a > constant to sort that out. > > As for the rest of the code, nearly *any* structure one could devise > would be clearer than this. If you''re using AR but not Rails, the > *least* you could do would be to split out the model definitions into > files and ''require'' them in all at the top... > > --Matt JonesHow can I require the models in helper. Can you give me any example with code..? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.