b0deafc53e
* all the good changes * follows * dont send duplicates * remove follow_type for now * dont add all the extra stuff we're not implementing yet * refactor * lots of fixes * Delete activity.html.erb * Delete activity.text.erb * Update 20170209215819_create_follows.rb * Update schema.rb * Update mapping.rb * Update mailboxer.rb
19 lines
492 B
Ruby
19 lines
492 B
Ruby
# frozen_string_literal: true
|
|
class Follow < ApplicationRecord
|
|
|
|
belongs_to :user
|
|
belongs_to :followed, polymorphic: true
|
|
has_one :follow_reason, dependent: :destroy
|
|
|
|
validates :user, presence: true
|
|
validates :followed, presence: true
|
|
validates :user, uniqueness: { scope: :followed, message: 'This entity is already followed by this user' }
|
|
|
|
after_create :add_subsetting
|
|
|
|
private
|
|
|
|
def add_subsetting
|
|
follow_reason = FollowReason.create!(follow: self)
|
|
end
|
|
end
|