Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Active Record Associations in Rails More Association Options Polymorphic "Belongs To" Associations

Justin Muzzi
Justin Muzzi
3,476 Points

Update the Part model class so that each instance belongs to a "vehicle".

Not sure were the error is occurring, I attempting using the has_many, and other combination to develop the association, yet I am missing something.

models/part.rb
class Part < ApplicationRecord
  # YOUR CODE HERE
  belongs_to :vehicle as: :Cars;
  belongs_to :vehicle as: :Trucks;
end
Vincent Fuentes
Vincent Fuentes
4,466 Points

belongs_to :vehicle, polymorphic: true