我有两个集合,即员工和部门。在那我使用has_many和belongs_to从部门引用了员工集合的department_id字段
class Employee
include Mongoid::Document
field :name, type: String
field :age, type: Integer
field :empid, type: String
field :manager_id, type: Integer
field :department_id, type:Integer
attr_accessible :age, :empid, :name, :department_id, :manager_id
validates_presence_of :name
validates_uniqueness_of :empid
belongs_to :department
end
class Department
include Mongoid::Document
field :name, type: String
attr_accessible :name
has_many :employees
end
现在我想使用员工来引用部门集合的_id,帮帮我