Sha256: fc55faa76bdb3cd4f03d3d50c85e8841e5f86e88a01453135d9497d7463979e2

Contents?: true

Size: 490 Bytes

Versions: 10

Compression:

Stored size: 490 Bytes

Contents

module FlexibleFeeds
  class Follow < ActiveRecord::Base
    belongs_to :follower, polymorphic: true
    belongs_to :feed

    validates :follower, presence: true
    validates :feed, presence: true
    validate :the_join_table_is_unique

    private
    def the_join_table_is_unique
      if FlexibleFeeds::Follow.where(feed: self.feed, follower: self.follower).
        exists?
          errors[:base] << I18n.t("activerecord.errors.models.follow.not_unique")
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
flexible_feeds-0.4.0 app/models/flexible_feeds/follow.rb
flexible_feeds-0.3.6 app/models/flexible_feeds/follow.rb
flexible_feeds-0.3.5 app/models/flexible_feeds/follow.rb
flexible_feeds-0.3.4 app/models/flexible_feeds/follow.rb
flexible_feeds-0.3.3 app/models/flexible_feeds/follow.rb
flexible_feeds-0.3.2 app/models/flexible_feeds/follow.rb
flexible_feeds-0.3.1 app/models/flexible_feeds/follow.rb
flexible_feeds-0.3.0 app/models/flexible_feeds/follow.rb
flexible_feeds-0.2.1 app/models/flexible_feeds/follow.rb
flexible_feeds-0.1.0 app/models/flexible_feeds/follow.rb