Gregory Brown
8/3/2008 9:59:00 PM
On Sun, Aug 3, 2008 at 5:48 PM, laredotornado <laredotornado@zipmail.com> 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