Sha256: dc30a778bdff9523bc9852b4a721f447250b3e49c74dd3bbc6191d4e38da9260
Contents?: true
Size: 918 Bytes
Versions: 2
Compression:
Stored size: 918 Bytes
Contents
module Spree class BrontoList < ActiveRecord::Base has_and_belongs_to_many :users, class_name: "Spree::User", join_table: :spree_bronto_lists_users belongs_to :store, class_name: "Spree::Store" validates_presence_of :title validates_uniqueness_of :list_id, :message => I18n.t("bronto.validate_unique") #validates_numericality_of :list_id scope :by_store, lambda { |store| joins(:stores).where("spree_bronto_lists.store_id = ?", store) } def validate if self.new_record? errors.add_to_base I18n.translate("bronto.only_list_can_subscribe_all") if self.subscribe_all_new_users && BrontoList.exists?(["subscribe_all_new_users = ?" , true]) else errors.add_to_base I18n.translate("bronto.only_list_can_subscribe_all") if self.subscribe_all_new_users && BrontoList.exists?(["subscribe_all_new_users = ? AND id <> ?" , true, self.id]) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spree_bronto-3.pre.0.pre.stable | app/models/spree/bronto_list.rb |
spree_bronto-3.0.0 | app/models/spree/bronto_list.rb |