I’ve created a fairly simple new method in one of my models. However, when I go to the rails console to test it, I get the following error:
NoMethodError: undefined method 'get' for #<Class:0x3a5032fc>
I have saved the code, closed the rails console and then restarted, but I still get the NoMethod
class Race <ActiveRecord::Base
def get(race_date,track_name,race_number)
Race.where(:date =>race_date, :race_nbr => race_number, :track_id => (Track.where(:track_code => track_name)))
end
end
In the console, I enter the following:
Race.get("2011-12-04", "BEL", 1)
which yields the NoMethodError:undefined method 'get'.
Any thoughts would be appreciated.
You defined an instance method of the class Race. Maybe you would have defined a class method like:
Then you can use
Race.get.