I have a (polymorphic) object Comment
(which will be used for Vehicle
and Review
objects). How can I get all comments
for User
's Vehicle
s: @user.vehicles.comments
? It says that method comments
is undefined for ActiveRecord::Relation
. Any simple way to get it working? Is it many-to-many relation: many vehicles have many comments? Or am I wrong? @user.vehicles.first.comments
works properly.
Relationships between objects (not full):
User
has_many Vehicles.
Vehicle
belongs_to User.
has_many Comments (as commentable).
Comment
belongs_to Commentable, :polymorphic => true