mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-11 01:05:01 -04:00
foreign key declarations not needed anymore
This commit is contained in:
@@ -4,8 +4,7 @@ module Ownable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
belongs_to :owner, class_name: 'Member',
|
||||
foreign_key: 'owner_id', counter_cache: true
|
||||
belongs_to :owner, class_name: 'Member', counter_cache: true
|
||||
|
||||
default_scope { joins(:owner).merge(Member.kept) } # Ensures the owner still exists
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ class Photo < ApplicationRecord
|
||||
|
||||
PHOTO_CAPABLE = %w(Garden Planting Harvest Seed Post Crop).freeze
|
||||
|
||||
has_many :photo_associations, foreign_key: :photo_id, dependent: :delete_all, inverse_of: :photo
|
||||
has_many :photo_associations, dependent: :delete_all, inverse_of: :photo
|
||||
|
||||
# This doesn't work, ActiveRecord tries to use the polymoriphinc photographable
|
||||
# relationship instead.
|
||||
|
||||
@@ -25,10 +25,9 @@ class Planting < ApplicationRecord
|
||||
|
||||
#
|
||||
# Ancestry of food
|
||||
belongs_to :parent_seed, class_name: 'Seed', # parent
|
||||
foreign_key: 'parent_seed_id',
|
||||
optional: true,
|
||||
inverse_of: :child_plantings
|
||||
belongs_to :parent_seed, class_name: 'Seed', # parent,
|
||||
optional: true,
|
||||
inverse_of: :child_plantings
|
||||
has_many :child_seeds, class_name: 'Seed', # children
|
||||
foreign_key: 'parent_planting_id',
|
||||
inverse_of: :parent_planting,
|
||||
|
||||
@@ -14,10 +14,10 @@ class Post < ApplicationRecord
|
||||
has_many :crop_posts, dependent: :delete_all
|
||||
has_many :crops, through: :crop_posts
|
||||
|
||||
after_create :send_notification
|
||||
#
|
||||
# Triggers
|
||||
after_save :update_crop_posts_association
|
||||
after_create :send_notification
|
||||
|
||||
default_scope { joins(:author).merge(Member.kept) } # Ensures the owner still exists
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class Seed < ApplicationRecord
|
||||
#
|
||||
# Relationships
|
||||
belongs_to :crop
|
||||
belongs_to :parent_planting, class_name: 'Planting', foreign_key: 'parent_planting_id',
|
||||
belongs_to :parent_planting, class_name: 'Planting',
|
||||
optional: true, inverse_of: :child_seeds # parent
|
||||
has_many :child_plantings, class_name: 'Planting',
|
||||
foreign_key: 'parent_seed_id', dependent: :nullify,
|
||||
|
||||
Reference in New Issue
Block a user