I’m pretty new to Rails, and I think my app has progressed quicker than
my knowledge of Rails/Ruby has …
I have the following models:
[ – Begin – ]
class Provider < ActiveRecord::Base
has_many :invoices
has_one :user
def self.get_invoices
invoices.find(:all)
end
end
class User < ActiveRecord::Base
belongs_to :Provider
belongs_to :Consumer
def invoices_raised
Provider.get_invoices
end
…
end
[ – End – ]
and when I call User.invoices_raised I get this error:
undefined local variable or method `invoices’ for Provider:Class
Now I thought that having the “has_many :invoices” line would
automatically make the connection and let me access “invoices” like
that, but obviously I’m wrong. Anyone care to correct me?
Cheers,
-S