如何在有作用域的用户(assigned_user
)之间实现HABTM关系
和评估模型,我有users
和assessments
模型
user.rb
devise :database_authenticatable,
:recoverable, :rememberable, :validatable
has_many :assessments
end
assessment.rb
class Assessment < ApplicationRecord
belongs_to :user
has_and_belongs_to_many :assigned_user, class_name: 'User'
scope :assigned_user, -> { where('user.role == proctor') }
end
如何在范围assigned_user
和assessments
之间创建联接表