我有一个(多态)对象Comment(将用于Vehicle和Review对象)。我怎样才能得到所有comments的Users Vehicle: @user.vehicles.comments?它说该方法comments未定义ActiveRecord::Relation。有什么简单的方法让它工作吗?是否是多对多关系:很多车辆有很多评论?还是我错了?@user.vehicles.first.comments工作正常。
对象之间的关系(不完整):
User
has_many Vehicles.
Vehicle
belongs_to User.
has_many Comments (as commentable).
Comment
belongs_to Commentable, :polymorphic => true