From: Gregory Brown Date: 2008-08-04T06:59:21+09:00 Subject: Re: Why am I getting "undefined method" error? On Sun, Aug 3, 2008 at 5:48 PM, laredotornado wrote: > Hi, > > I have a model, in which I have defined a method ... > > class Form < ActiveRecord::Base > has_many :form_items > validates_associated :form_items > > ... > > def self.has_items > FormItem.count(:all, :conditions => ["form_id > = ?", :id]) > end > end > You defined a class method, then used it on an instance. You want an instance method, so remove self. from in front of the method definition. Also, you are passing a symbol instead of the actual id, so you'll need to fix that too: def has_items FormItem.count(:all, :conditions => ["form_id = ?", id]) end -greg