我的用户模型有很多设计,而且还有很多design_request通过设计
现在我的design_request模型has_one命令。如何通过订单状态==“付费”为用户获取所有设计请求
my user model is below
##User Model
has_many :designs
has_many :design_requests, through: :designs
##Design Model
has_many :design_requests
##Design Request Model
belongs_to :design
belongs_to :user
validates :business_name, :design_id, presence: true
delegate :name, to: :design
has_one :order, as: :item
答案 0 :(得分:1)
user.design_requests.includes(:order).where(orders: {state: "paid"})
答案 1 :(得分:0)
这有用吗? user.design_requests.select {| dr | dr.order.state ==“付费”}