Sha256: 55be2cba9dceb11fb0d30cda73e53e2695048cc64b8e02f0d53457a4056896a2

Contents?: true

Size: 541 Bytes

Versions: 3

Compression:

Stored size: 541 Bytes

Contents

module Partisan
  class Follow < ActiveRecord::Base
    self.table_name = 'follows'

    # Validations
    validates :followable, presence: true
    validates :follower, presence: true

    # Associations
    belongs_to :followable, polymorphic: true
    belongs_to :follower, polymorphic: true

    # Callbacks
    after_create :update_follow_counter
    after_destroy :update_follow_counter

  protected

    def update_follow_counter
      self.follower.update_follow_counter
      self.followable.update_follow_counter
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
partisan-0.1.1 lib/partisan/follow.rb
partisan-0.1 lib/partisan/follow.rb
partisan-0.0.1 lib/partisan/follow.rb