I trying to implement a memoized_finder method and I am getting an error that I don’t understand.
My method follows:
class Module
def memoized_finder(name, conditions=nil)
class_eval <<-STR
def #{name}(reload=false)
@#{name} = nil if reload
@#{name} ||= find(:all, :conditions => #{conditions.inspect})
end
STR
end
end
This is resulting in the following error:
SyntaxError: (eval):3: odd number list for Hash. @sire ||= find(:all, :conditions => {conditions.inspect})
I have googled around but can’t come up with what is going wrong.
Note: The method I’m using come from a great article on Extending Activerecord Associations. Here’s the link if anyone want’s to have a look:http://weblog.jamisbuck.org/2007/1/9/extending-activerecord-associations
Thanks for your input.
It turns out that my jruby installation is based upon a version of rails that is not compatible with the memoized_finder method.