Files
grecia/app/models/concerns/followable.rb
2017-07-25 13:01:03 +02:00

14 lines
255 B
Ruby

module Followable
extend ActiveSupport::Concern
included do
has_many :follows, as: :followable, dependent: :destroy
has_many :followers, through: :follows, source: :user
end
def followed_by?(user)
followers.include?(user)
end
end