Sha256: 3691feddd84e65a65e285656c195cc724789dbfde2788412ab855c2e58677d57
Contents?: true
Size: 660 Bytes
Versions: 13
Compression:
Stored size: 660 Bytes
Contents
class ListItem < ActiveRecord::Base include Concerns::Model::BaseListItem attr_accessible :list_id, :thing, :thing_type, :thing_id, :best, :stars has_many :user_list_items, dependent: :destroy validates :thing_id, presence: true, uniqueness: { scope: [:list_id, :thing_type] } validate :type_equals_thing_type_of_list acts_as_list scope: :list private def type_equals_thing_type_of_list return unless list_thing_type = list.try(:thing_type) unless list_thing_type == thing_type errors[:thing_type] << I18n.t('activerecord.errors.models.list_item.attributes.thing_type.no_valid_type_for_list') end end end
Version data entries
13 entries across 13 versions & 1 rubygems