Sha256: bf33263772c810b5e198d3040f50c35e18374b6a864496ac7cc8545ec3b957a9

Contents?: true

Size: 515 Bytes

Versions: 10

Compression:

Stored size: 515 Bytes

Contents

module FlexibleFeeds
  class ModeratorJoin < ActiveRecord::Base
    belongs_to :feed
    belongs_to :moderator, polymorphic: true

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

    private
    def the_join_table_is_unique
      if FlexibleFeeds::ModeratorJoin.where(feed: self.feed,
        moderator: self.moderator).exists?
          errors[:base] << I18n.t("activerecord.errors.models.moderator_join.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/moderator_join.rb
flexible_feeds-0.3.6 app/models/flexible_feeds/moderator_join.rb
flexible_feeds-0.3.5 app/models/flexible_feeds/moderator_join.rb
flexible_feeds-0.3.4 app/models/flexible_feeds/moderator_join.rb
flexible_feeds-0.3.3 app/models/flexible_feeds/moderator_join.rb
flexible_feeds-0.3.2 app/models/flexible_feeds/moderator_join.rb
flexible_feeds-0.3.1 app/models/flexible_feeds/moderator_join.rb
flexible_feeds-0.3.0 app/models/flexible_feeds/moderator_join.rb
flexible_feeds-0.2.1 app/models/flexible_feeds/moderator_join.rb
flexible_feeds-0.1.0 app/models/flexible_feeds/moderator_join.rb