Model Methods

I would like to write a few custom methods for my model, but keep
getting an error saying the method is not defined for the model (playing
in the console).

For example, I have a product model, and I want a method called stocked?
that will return 'yes' or 'no' depending on an in_stock boolean field
for the model:

class Product < ActiveRecord::Base
def self.stocked?
   self.in_stock ? 'yes' : 'no'
end
end

How would I fix this?...

don’t think you need the ‘self’ after def.

That method should be an instance method instead of a class method, since you want to be able to ask each product whether it’s stocked.

Regards,
Craig