Payment.find_by_person_and_event

Hey, I need help with a little something that I thought SHOULD work.

I’m getting this error:
ActionView::TemplateError (undefined method `find_by_person_and_event’
for Payment:Class) on line #2 of app/views/people/_attending.rhtml:
1: <% for event in @person.events %>
2: <% payment = Payment.find_by_person_and_event(@person,event) %>
3: Attending <%= event.name %>, as a <%= payment.price.name %>.
4:
5:

But here’s my Payment class, it looks correct:
class Payment < ActiveRecord::Base
has_many :attendances
has_many :person, :through => :attendance
has_many :event, :through => :attendance
belongs_to :price
end

Any ideas why those find_by methods simply are not working? Rails
never likes me when it comes to using them… I still haven’t figured
out the enigma.

On 11 May 2008, at 18:10, kopf1988 wrote:

5:

But here’s my Payment class, it looks correct:
class Payment < ActiveRecord::Base
has_many :attendances
has_many :person, :through => :attendance
has_many :event, :through => :attendance
belongs_to :price
end

They work on database attributes (not association names or anything
like that) so the method you’re after is
find_by_person_id_and_event_id (and you’ll probably need to pass in
@person.id instead of @person etc…)

Fred