誰かがオーバーライドする方法を見つけるのを手伝ってくれませんかdefault_scope
。
私の見解では、すべての一致を表示する必要があるmatches
だけでなく、{ where("match_date >= now()") }
すべてを表示する必要があります。default_scope を使用する理由があります。私はRailsで非常に新しいです。unscoped を使用しようとしましたが、役に立たなかったか、適切に使用していませんでした。助言がありますか?ありがとう!
class Reservation < ActiveRecord::Base
belongs_to :bar_match
end
class BarMatch < ActiveRecord::Base
belongs_to :bar
belongs_to :match
has_many :reservations
end
class Match < ActiveRecord::Base
has_many :bars, through: :bar_matches
has_many :bar_matches, dependent: :destroy
default_scope { where("match_date >= now()") }
end
コントローラ
@reservations = Reservation.where(user_id: current_user.id)
意見
- @reservations.each do |reservation|
= reservation.bar_match.match