Sha256: 82a04cffd2f88ae1ac963ef5dad5bf8da1dd1c193e2ab49a2fb963e2c653a22f
Contents?: true
Size: 816 Bytes
Versions: 12
Compression:
Stored size: 816 Bytes
Contents
basket[:non_createable_types] = [:mod] def cards_of_type_exist? !new_card? && Card.where(trash: false, type_id: id).exists? end def create_ok? Card.new(type_id: id).ok? :create end def was_cardtype? type_id_before_act == Card::CardtypeID end event :check_for_cards_of_type, after: :validate_delete do errors.add :cardtype, t(:core_cards_exist, cardname: name) if cards_of_type_exist? end event :check_for_cards_of_type_when_type_changed, :validate, changing: :type, when: :was_cardtype? do if cards_of_type_exist? errors.add :cardtype, t(:core_error_cant_alter, name: name_before_act) end end event :validate_cardtype_name, :validate, on: :save, changed: :name do if %r{[<>/]}.match?(name) errors.add :name, t(:core_error_invalid_character_in_cardtype, banned: "<, >, /") end end
Version data entries
12 entries across 12 versions & 1 rubygems