I am trying to create an array of ids so that I can query if a certain id is associated with an object. Here is my method but it isnt adding id's to the array.
class Report
include Mongoid::Document
has_and_belongs_to_many :reportapprovals, class_name: "Reportapproval", inverse_of: :report
def bind_reportapproval
@reportapprovals = Reportapproval.where(tenant_id: self.tenant_id).all
if @reportapprovals.present? && @reportapprovals.any? { |ra| ra.tenant_approved == true }
@reportapprovals.each do |ra|
self.reportapproval_ids = ra.id
end
end
end
end
This is suppose to add an array of reportapproval_ids to the report object.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire