Chris Olsen
2008-Aug-27 08:11 UTC
Getting "undefined method `macro''" for different classes
I am not sure what is causing this. As mentioned I am getting the same error from different classes and no where do I have a custom macro method. I have reset the server a few times, but I still get the same thing. The code running on the live server works fine. Although I have made some changes, none of them are related to data access. Any ideas? === One of the cases is happening on the following call: game_dates = GameDate.find( :all, :conditions => "season_id #{self.id}", :include => [{:bookings => :location}]) NoMethodError (undefined method `macro'' for #<GameDate:0x1eb1940>): /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/attribute_methods.rb:256:in `method_missing'' /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:40:in `preload_one_association'' /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:38:in `each'' /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:38:in `preload_one_association'' /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:17:in `preload_associations'' /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:21:in `preload_associations'' /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:19:in `each'' /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:19:in `preload_associations'' /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:16:in `preload_associations'' /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:16:in `each'' /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:16:in `preload_associations'' /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1343:in `find_every'' /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:536:in `find'' /app/models/season.rb:54:in `create_games'' -- 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Aug-27 08:25 UTC
Re: Getting "undefined method `macro''" for different classes
On 27 Aug 2008, at 09:11, Chris Olsen wrote:> > I am not sure what is causing this. As mentioned I am getting the > same > error from different classes and no where do I have a custom macro > method. > > I have reset the server a few times, but I still get the same thing. > The code running on the live server works fine. Although I have made > some changes, none of them are related to data access.> Any ideas? >What''s in your models ? I''d guess that you''ve accidentally overwritten an activerecord method, Fred> ===> > One of the cases is happening on the following call: > > game_dates = GameDate.find( :all, > :conditions => "season_id > #{self.id}", > :include => [{:bookings => > :location}]) > > > NoMethodError (undefined method `macro'' for #<GameDate:0x1eb1940>): > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > attribute_methods.rb:256:in > `method_missing'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > association_preload.rb:40:in > `preload_one_association'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > association_preload.rb:38:in > `each'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > association_preload.rb:38:in > `preload_one_association'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > association_preload.rb:17:in > `preload_associations'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > association_preload.rb:21:in > `preload_associations'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > association_preload.rb:19:in > `each'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > association_preload.rb:19:in > `preload_associations'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > association_preload.rb:16:in > `preload_associations'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > association_preload.rb:16:in > `each'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > association_preload.rb:16:in > `preload_associations'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > base.rb:1343:in > `find_every'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > base.rb:536:in > `find'' > /app/models/season.rb:54:in `create_games'' > -- > 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 -~----------~----~----~----~------~----~------~--~---
Franz Strebel
2008-Aug-27 08:38 UTC
Re: Getting "undefined method `macro''" for different classes
On Wed, Aug 27, 2008 at 10:25 AM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > What''s in your models ? I''d guess that you''ve accidentally overwritten > an activerecord method, > >Particularly in the Season model and its method create_games as indicated at the bottom of the errors:> /app/models/season.rb:54:in `create_games''--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
\"Wolas!\"
2008-Aug-27 09:27 UTC
Re: Getting "undefined method `macro''" for different classes
shouldnt it be :conditions => ["season_id = ?", id] or :conditions => {:season_id => self}, instead of :conditions => "season_id =#{self.id}", Chris Olsen wrote:> I am not sure what is causing this. As mentioned I am getting the same > error from different classes and no where do I have a custom macro > method. > > I have reset the server a few times, but I still get the same thing. > The code running on the live server works fine. Although I have made > some changes, none of them are related to data access. > > Any ideas? > > ===> > One of the cases is happening on the following call: > > game_dates = GameDate.find( :all, > :conditions => "season_id > #{self.id}", > :include => [{:bookings => > :location}]) > > > NoMethodError (undefined method `macro'' for #<GameDate:0x1eb1940>): > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/attribute_methods.rb:256:in > `method_missing'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:40:in > `preload_one_association'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:38:in > `each'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:38:in > `preload_one_association'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:17:in > `preload_associations'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:21:in > `preload_associations'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:19:in > `each'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:19:in > `preload_associations'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:16:in > `preload_associations'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:16:in > `each'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/association_preload.rb:16:in > `preload_associations'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1343:in > `find_every'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:536:in > `find'' > /app/models/season.rb:54:in `create_games'' > -- > 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Aug-27 09:45 UTC
Re: Getting "undefined method `macro''" for different classes
On 27 Aug 2008, at 10:27, Wolas! wrote:> > shouldnt it be > > :conditions => ["season_id = ?", id] > > or > > :conditions => {:season_id => self}, > > instead of > > :conditions => "season_id =#{self.id}",All three will work. the latter opens a window for injection nastiness. Fred> > > Chris Olsen wrote: >> I am not sure what is causing this. As mentioned I am getting the >> same >> error from different classes and no where do I have a custom macro >> method. >> >> I have reset the server a few times, but I still get the same thing. >> The code running on the live server works fine. Although I have made >> some changes, none of them are related to data access. >> >> Any ideas? >> >> ===>> >> One of the cases is happening on the following call: >> >> game_dates = GameDate.find( :all, >> :conditions => "season_id >> #{self.id}", >> :include => [{:bookings => >> :location}]) >> >> >> NoMethodError (undefined method `macro'' for #<GameDate:0x1eb1940>): >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ >> attribute_methods.rb:256:in >> `method_missing'' >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ >> association_preload.rb:40:in >> `preload_one_association'' >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ >> association_preload.rb:38:in >> `each'' >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ >> association_preload.rb:38:in >> `preload_one_association'' >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ >> association_preload.rb:17:in >> `preload_associations'' >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ >> association_preload.rb:21:in >> `preload_associations'' >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ >> association_preload.rb:19:in >> `each'' >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ >> association_preload.rb:19:in >> `preload_associations'' >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ >> association_preload.rb:16:in >> `preload_associations'' >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ >> association_preload.rb:16:in >> `each'' >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ >> association_preload.rb:16:in >> `preload_associations'' >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ >> base.rb:1343:in >> `find_every'' >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ >> base.rb:536:in >> `find'' >> /app/models/season.rb:54:in `create_games'' >> -- >> 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 > -~----------~----~----~----~------~----~------~--~--- >
\"Wolas!\"
2008-Aug-27 14:55 UTC
Re: Getting "undefined method `macro''" for different classes
Thx Fred! On Aug 27, 10:45 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 27 Aug 2008, at 10:27, Wolas! wrote: > > > > > shouldnt it be > > > :conditions => ["season_id = ?", id] > > > or > > > :conditions => {:season_id => self}, > > > instead of > > > :conditions => "season_id =#{self.id}", > > All three will work. the latter opens a window for injection nastiness. > > Fred > > > > > Chris Olsen wrote: > >> I am not sure what is causing this. As mentioned I am getting the > >> same > >> error from different classes and no where do I have a custom macro > >> method. > > >> I have reset the server a few times, but I still get the same thing. > >> The code running on the live server works fine. Although I have made > >> some changes, none of them are related to data access. > > >> Any ideas? > > >> ===> > >> One of the cases is happening on the following call: > > >> game_dates = GameDate.find( :all, > >> :conditions => "season_id > >> #{self.id}", > >> :include => [{:bookings => > >> :location}]) > > >> NoMethodError (undefined method `macro'' for #<GameDate:0x1eb1940>): > >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > >> attribute_methods.rb:256:in > >> `method_missing'' > >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > >> association_preload.rb:40:in > >> `preload_one_association'' > >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > >> association_preload.rb:38:in > >> `each'' > >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > >> association_preload.rb:38:in > >> `preload_one_association'' > >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > >> association_preload.rb:17:in > >> `preload_associations'' > >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > >> association_preload.rb:21:in > >> `preload_associations'' > >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > >> association_preload.rb:19:in > >> `each'' > >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > >> association_preload.rb:19:in > >> `preload_associations'' > >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > >> association_preload.rb:16:in > >> `preload_associations'' > >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > >> association_preload.rb:16:in > >> `each'' > >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > >> association_preload.rb:16:in > >> `preload_associations'' > >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > >> base.rb:1343:in > >> `find_every'' > >> /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/ > >> base.rb:536:in > >> `find'' > >> /app/models/season.rb:54:in `create_games'' > >> -- > >> Posted viahttp://www.ruby-forum.com/. > > > > > > smime.p7s > 5KViewDownload--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Chris Olsen
2008-Aug-27 15:43 UTC
Re: Getting "undefined method `macro''" for different classes
Franz Strebel wrote:> On Wed, Aug 27, 2008 at 10:25 AM, Frederick Cheung < > frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> What''s in your models ? I''d guess that you''ve accidentally overwritten >> an activerecord method, >> >> > Particularly in the Season model and its method create_games > as indicated at the bottom of the errors:It turns out the error is in a couple of custom method I added to the Array class, although I am not sure where the overlap is. These are the methods I added to lib/array.rb. class Array def group groups = {} self.each do |item| groups[item] ||= [] groups[item] << item end groups end def group_by(&block) groups = {} self.each do |item| val = yield(item) groups[item] ||= [] groups[item] << val end groups end end -- 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Aug-27 15:59 UTC
Re: Getting "undefined method `macro''" for different classes
On 27 Aug 2008, at 16:43, Chris Olsen wrote:> > Franz Strebel wrote: >> On Wed, Aug 27, 2008 at 10:25 AM, Frederick Cheung < >> frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> >>> What''s in your models ? I''d guess that you''ve accidentally >>> overwritten >>> an activerecord method, >>> >>> >> Particularly in the Season model and its method create_games >> as indicated at the bottom of the errors: > > It turns out the error is in a couple of custom method I added to the > Array class, although I am not sure where the overlap is. > > These are the methods I added to lib/array.rb.There is already a method group_by in rails, you''ve overwritten it with one which different meaning rails: >> [1,2,3,''Foo'', ''Boo''].group_by {|r| r.class} => [[Fixnum, [1, 2, 3]], [String, ["Foo", "Boo"]]] you: [1,2,3,''Foo'', ''Boo''].group_by {|r| r.class} => {"Boo"=>[String], 1=>[Fixnum], 2=>[Fixnum], "Foo"=>[String], 3=>[Fixnum]} which doesn''t seem to be doing anything useful, at least not in the way rails uses it Fred> > > class Array > def group > groups = {} > self.each do |item| > groups[item] ||= [] > groups[item] << item > end > groups > end > > def group_by(&block) > groups = {} > self.each do |item| > val = yield(item) > groups[item] ||= [] > groups[item] << val > end > groups > end > end > -- > 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 -~----------~----~----~----~------~----~------~--~---
Chris Olsen
2008-Aug-27 17:58 UTC
Re: Getting "undefined method `macro''" for different classes
Thanks for the help Fred. -- 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 -~----------~----~----~----~------~----~------~--~---