Forked from
PortalMEC / portalmec
1205 commits behind the upstream repository.
-
Israel Barreto Sant'Anna authored
Signed-off-by:
Israel Barreto Sant'Anna <ibsa14@inf.ufpr.br>
Israel Barreto Sant'Anna authoredSigned-off-by:
Israel Barreto Sant'Anna <ibsa14@inf.ufpr.br>
follow.rb 631 B
# == Schema Information
#
# Table name: follows
#
# id :integer not null, primary key
# followable_id :integer
# followable_type :string
# user_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Follow < ApplicationRecord
# *current_user* follows *followable*
include Trackable
belongs_to :followable, polymorphic: true, counter_cache: true
belongs_to :user
validates_presence_of :user, :followable
validates :user_id, uniqueness: { scope: [:followable_id, :followable_type] }
def recipient
followable
end
end