Define ticket_purchases before through association
In the User model, a has_many :through association 'User#physical_tickets' which goes through 'User#ticket_purchases' was defined before the through association was defined. This doesn't work in Rails 5.1.
This commit is contained in:
parent
41d6fad7a5
commit
7473e889ee
1 changed files with 1 additions and 1 deletions
|
|
@ -11,6 +11,7 @@ class User < ApplicationRecord
|
||||||
# prevent N+1 queries with has_cached_role? by preloading roles *always*
|
# prevent N+1 queries with has_cached_role? by preloading roles *always*
|
||||||
default_scope { preload(:roles) }
|
default_scope { preload(:roles) }
|
||||||
|
|
||||||
|
has_many :ticket_purchases, dependent: :destroy
|
||||||
has_many :physical_tickets, through: :ticket_purchases do
|
has_many :physical_tickets, through: :ticket_purchases do
|
||||||
def by_conference(conference)
|
def by_conference(conference)
|
||||||
where('ticket_purchases.conference_id = ?', conference)
|
where('ticket_purchases.conference_id = ?', conference)
|
||||||
|
|
@ -67,7 +68,6 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
has_many :events_registrations, through: :registrations
|
has_many :events_registrations, through: :registrations
|
||||||
has_many :ticket_purchases, dependent: :destroy
|
|
||||||
has_many :payments, dependent: :destroy
|
has_many :payments, dependent: :destroy
|
||||||
has_many :tickets, through: :ticket_purchases, source: :ticket do
|
has_many :tickets, through: :ticket_purchases, source: :ticket do
|
||||||
def for_registration conference
|
def for_registration conference
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue