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:inmethod_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:ineach’
/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:inpreload_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:ineach’
/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:inpreload_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:inpreload_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:infind’
/app/models/season.rb:54:in `create_games’

On 27 Aug 2008, at 09:11, Chris O. 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

On Wed, Aug 27, 2008 at 10:25 AM, Frederick C. <
[email protected]> 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:

shouldnt it be

:conditions => [“season_id = ?”, id]

or

:conditions => {:season_id => self},

instead of

:conditions => “season_id =#{self.id}”,

Thx Fred!

On Aug 27, 10:45 am, Frederick C. [email protected]

On 27 Aug 2008, at 10:27, Wolas! wrote:

:conditions => “season_id =#{self.id}”,

All three will work. the latter opens a window for injection nastiness.

Fred

On 27 Aug 2008, at 16:43, Chris O. wrote:

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

Franz S. wrote:

On Wed, Aug 27, 2008 at 10:25 AM, Frederick C. <
[email protected]> 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

Thanks for the help Fred.