I have a stock model and supply model and stock belongs to supply model.
I want to sort stock records based on "date_received" attribute of supply model
Stock.where("seller_id = ? AND status = ? AND product_id = ?", @seller_id, "Approved", list_item.product_id)
I am getting error for below:
Stock.includes(:supply).where("seller_id = ? AND status = ? AND product_id = ?", @seller_id, "Approved", list_item.product_id).order("supply.date_received")