class Channel < ActiveRecord::Base attr_accessible :bot_id, :name, :activate # Relation belongs_to :bot # Validation validates :name, :uniqueness => true, :presence => true, :format => { :with => /\A#\S+\z/, :message => "Channel name must begin with # and no whitespace in name allowed" } validates_presence_of :bot_id validates_presence_of :bot_id, :on => :update end