diff --git a/src/supermarket/app/models/cookbook.rb b/src/supermarket/app/models/cookbook.rb index 41a59ea060..3b0c0dfc6a 100644 --- a/src/supermarket/app/models/cookbook.rb +++ b/src/supermarket/app/models/cookbook.rb @@ -95,7 +95,7 @@ class Cookbook < ApplicationRecord belongs_to :category, optional: true belongs_to :owner, class_name: "User", foreign_key: :user_id, inverse_of: :owned_cookbooks has_one :chef_account, through: :owner - belongs_to :replacement, class_name: "Cookbook", foreign_key: :replacement_id, inverse_of: :replaces, optional: true + belongs_to :replacement, class_name: "Cookbook", inverse_of: :replaces, optional: true has_many :replaces, class_name: "Cookbook", foreign_key: :replacement_id, inverse_of: :replacement, dependent: :nullify has_many :collaborators, as: :resourceable, inverse_of: :resourceable # rubocop:disable Rails/HasManyOrHasOneDependent has_many :collaborator_users, through: :collaborators, source: :user diff --git a/src/supermarket/app/models/user.rb b/src/supermarket/app/models/user.rb index b7babf458e..43d0608e7d 100644 --- a/src/supermarket/app/models/user.rb +++ b/src/supermarket/app/models/user.rb @@ -7,7 +7,7 @@ class User < ApplicationRecord # Associations # -------------------- has_many :accounts - has_many :owned_cookbooks, class_name: "Cookbook", foreign_key: "user_id", inverse_of: :owner + has_many :owned_cookbooks, class_name: "Cookbook", inverse_of: :owner has_many :cookbook_versions has_many :collaborators has_many :cookbook_followers