I have following models and i wish search Order model with criteria related to models Department Supplier
Question is how to includes other models Supplier and Department in this code
@q = Order.ransack(params[:q])
@objednavky = @q.result.includes(:user,:food).page(params[:page])
Definitions of models
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