12345678910111213141516 |
- class Frequency < ActiveRecord::Base
- attr_accessible :delay, :description, :helpmsg, :name, :prefix, :activate
- # Relation
- has_many :bans, :dependent => :destroy, :inverse_of => :frequency
- accepts_nested_attributes_for :bans, :allow_destroy => true
- # Validation
- before_destroy :raise_if_last
- def raise_if_last
- if Frequency.count < 3
- raise "Can't delete last two frequencies"
- end
- end
- end
|