mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-02-06 15:41:09 -05:00
Merge remote-tracking branch 'origin/post-comments' into post-comments
This commit is contained in:
@@ -18,7 +18,7 @@ class Crop < ApplicationRecord
|
||||
belongs_to :requester, class_name: 'Member', optional: true, inverse_of: :requested_crops
|
||||
belongs_to :parent, class_name: 'Crop', optional: true, inverse_of: :varieties
|
||||
has_many :varieties, class_name: 'Crop', foreign_key: 'parent_id', dependent: :nullify, inverse_of: :parent
|
||||
has_many :crop_posts
|
||||
has_many :crop_posts, dependent: :delete_all
|
||||
has_many :posts, through: :crop_posts, dependent: :delete_all
|
||||
|
||||
##
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class CropPost < ApplicationRecord
|
||||
belongs_to :crop
|
||||
belongs_to :post
|
||||
end
|
||||
end
|
||||
|
||||
@@ -64,7 +64,7 @@ class Post < ApplicationRecord
|
||||
crop_name = Regexp.last_match(1)
|
||||
crop = Crop.case_insensitive_name(crop_name).first
|
||||
# create association
|
||||
self.crops << crop if crop && !crops.include?(crop)
|
||||
crops << crop if crop && !crops.include?(crop)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user