0
我ROR4有一個應用程序,它具有以下型號過濾:使一個類上委託的屬性
# Quotation model
class Quotation < ActiveRecord::Base
belongs_to :request
has_one :booking
has_one :review
has_one :coupon, class_name: 'Coupons::Models::CouponRedemption'
delegate :artist, to: :request
delegate :user, to: :request
end
我試圖做一個查詢,可以發現表明,以某一鏈接的所有報價的對象用戶。我試圖做到以下幾點:
# Scope to filter based on user
scope :_user, -> (user_id) { where user: user_id }
然而這返回「未定義的方法`用戶'」,你知道我做錯了什麼嗎?
你爲什麼範圍名以下劃線開頭? – Ilya
不是真的有理由,但我也可以使用它沒有下劃線。 – hY8vVpf3tyR57Xib