Merge remote-tracking branch 'origin/post-comments' into post-comments

This commit is contained in:
Brenda Wallace
2019-09-26 21:14:53 +12:00
3 changed files with 3 additions and 3 deletions

View File

@@ -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
##

View File

@@ -1,4 +1,4 @@
class CropPost < ApplicationRecord
belongs_to :crop
belongs_to :post
end
end

View File

@@ -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