我有以下模型,我希望搜索订单模型,其中包含与模型部门供应商相关的标准
问题是如何在此代码中包含其他模型供应商和部门
@q = Order.ransack(params[:q])
@objednavky = @q.result.includes(:user,:food).page(params[:page])
模型的定义
class Supplier < ApplicationRecord
has_many :food
end
class User < ApplicationRecord
belongs_to :department
has_many :orders
end
class Department < ApplicationRecord
has_many :users
end
class Food < ApplicationRecord
belongs_to :supplier
has_many :order
end
class Order < ApplicationRecord
belongs_to :user
belongs_to :food
end