Cam wrote: > Hey All, > Forgive me for posting a question that may be very elementary. > > I'm building an application and am a bit stuck on how to work out the > associations. It goes like this: > > User :has_many vehicles > User :has_many logs > > Vehicle :has_many logs > > User -> Vehicles -> Logs > > The Vehicles have a user_id attribute. > The Logs have user_id and vehicle_id attributes. > > I am using restful authentication and am able to associate the > vehicles with the users al a > ----- > def create > @vehicle = current_user.vehicle.build (params[:vehicle]) > ...... > ------ > > I can't figure out how I should do it for the log. > Thanks again, and sorry for my lack of understanding of how rails > works.
You probably want to use has_many :through. Have you read the Rails guide on associations? > > Cheers, > > Cam Peterson Best, -- Marnen Laibow-Koser http://www.marnen.org [email protected] -- Posted via http://www.ruby-forum.com/. -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

