bot.rb 490 B

123456789101112131415161718192021
  1. class Bot < ActiveRecord::Base
  2. attr_accessible :botnick, :owner, :activate
  3. # Relation
  4. has_many :channels, :dependent => :destroy, :inverse_of => :bot
  5. accepts_nested_attributes_for :channels, :allow_destroy => true
  6. # Validation
  7. validates :botnick,
  8. :uniqueness => true,
  9. :presence => true,
  10. :format => { :with => /\A[a-zA-Z0-9]*+\z/, :message => "Channel name must be alphanumeric" }
  11. validates :owner,
  12. :presence => true
  13. end