Hi all I seem to have a small problem in Rails. Lets say I have a class Foo with an habtm association to Bar. So Foo has_and_belongs_to Bars en vice versa. Now, when I do lets say Foo.new Foo.bars, I get an undefined method bars for #<Foo:0x1034f2f00> when I run it through the browser. Now, when I do it through irb, it returns an empty array as expected. Does someone here has any clue how this can happen and what I need to look for, becouse I''m completely clueless. Thanks for any tips. -- 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 Mar 7, 7:42 pm, Michael Rigart <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi all > > I seem to have a small problem in Rails. Lets say I have a class Foo > with an habtm association to Bar. So Foo has_and_belongs_to Bars en vice > versa. > > Now, when I do lets say > > Foo.new > Foo.bars, I get an undefined method bars for #<Foo:0x1034f2f00> when I > run it through the browser. > > Now, when I do it through irb, it returns an empty array as expected. > Does someone here has any clue how this can happen and what I need to > look for, becouse I''m completely clueless. >Random guess: does this still occur in production mode ? Fred> Thanks for any tips. > -- > 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-/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.
Frederick Cheung wrote:> On Mar 7, 7:42�pm, Michael Rigart <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> run it through the browser. >> >> Now, when I do it through irb, it returns an empty array as expected. >> Does someone here has any clue how this can happen and what I need to >> look for, becouse I''m completely clueless. >> > Random guess: does this still occur in production mode ? > > Fredunfortunately is does -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Mar 7, 7:56 pm, Michael Rigart <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Frederick Cheung wrote: > > On Mar 7, 7:42 pm, Michael Rigart <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> run it through the browser. > > >> Now, when I do it through irb, it returns an empty array as expected. > >> Does someone here has any clue how this can happen and what I need to > >> look for, becouse I''m completely clueless. > > > Random guess: does this still occur in production mode ? > > > Fred > > unfortunately is does >Is Foo defined in multiple places (some editors leave behind backup copies of files that Rails loads anyway) ? If you stick a breakpoint in does the Foo object you have look normal apart from raising an error when bars is called ? Fred> -- > 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-/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.
On 7 March 2010 19:42, Michael Rigart <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi all > > I seem to have a small problem in Rails. Lets say I have a class Foo > with an habtm association to Bar. So Foo has_and_belongs_to Bars en vice > versa. > > Now, when I do lets say > > Foo.new > Foo.bars, I get an undefined method bars for #<Foo:0x1034f2f00> when I > run it through the browser.Foo.bars is not valid as Foo is a class not an instance, or is that just a typo here? It should be something like foo = Foo.new then use foo.bars Colin> > Now, when I do it through irb, it returns an empty array as expected. > Does someone here has any clue how this can happen and what I need to > look for, becouse I''m completely clueless. > > Thanks for any tips. > -- > 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. > >-- 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.
Colin Law wrote:> On 7 March 2010 19:42, Michael Rigart <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> run it through the browser. > Foo.bars is not valid as Foo is a class not an instance, or is that > just a typo here? It should be something like > foo = Foo.new > then use foo.bars > > Colin@Colin: yes, sorry for the mistake. I do run foo = Foo.new and then foo.bars. @Fred: just entered a break point. Seems like a normal object of type Foo with all its attributes present, except for the associations and self declared methods inside my model -- 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.
Frederick Cheung wrote:> On Mar 7, 7:56�pm, Michael Rigart <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> > Fred >> >> unfortunately is does >> > > Is Foo defined in multiple places (some editors leave behind backup > copies of files that Rails loads anyway) ? If you stick a breakpoint > in does the Foo object you have look normal apart from raising an > error when bars is called ? > > FredWhat just stuk me is that when I set a breakpoint at the class Foo < ActiveRecord::Base line, it doesn''t stop. It just runs through the application till it hits foo.bars :s -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.