Skip to content

Commit f3ca217

Browse files
committed
models: add inverse_of to WorkshopSponsor belongs_to :workshop
This enables proper Rails association caching when accessing workshop from a workshop_sponsor record, reducing redundant queries.
1 parent ddac753 commit f3ca217

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

app/models/workshop_sponsor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class WorkshopSponsor < ApplicationRecord
22
belongs_to :sponsor
3-
belongs_to :workshop
3+
belongs_to :workshop, inverse_of: :workshop_sponsors
44

55
validates :sponsor_id, uniqueness: { scope: :workshop_id, message: :already_sponsoring }
66
end

0 commit comments

Comments
 (0)