On 11 May 2008, at 18:10, kopf1988 wrote:
>
> 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
>
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
> 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.
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---