Could someone help me to find out how to override default_scope
.
In my view I have to show all matches
, not only { where("match_date >= now()") }
I need to display all matches. I have some reasone to use default_scope. I am very new in Rails. I tried to use unscoped, but it didn't help or I used it not properly. Any suggestions? Thanks!
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
Controller
@reservations = Reservation.where(user_id: current_user.id)
View
- @reservations.each do |reservation|
= reservation.bar_match.match