Sha256: 3b4ef9da6e547d3f5c7440775e91d7b34537e76e50b649bd76d887e79290bf8d

Contents?: true

Size: 659 Bytes

Versions: 6

Compression:

Stored size: 659 Bytes

Contents

class Player < ActiveRecord::Base
  validates_presence_of(:name)
  validates_numericality_of(:number, :only_integer => true)
  validates_uniqueness_of(:number, :scope => :team_id, :message => "There is already a player with that number on this team")

  validates_each :name do |record, attr, value|
    record.errors.add(:base, "Player is cheating") if value.to_s =~ /on steroids/
  end

  belongs_to :team, :inverse_of => :players
  has_one :draft, :dependent => :destroy

  has_many :comments, :as => :commentable
  attr_protected :suspended

  def draft_id
    self.draft.try :id
  end

  def draft_id=(id)
    self.draft = Draft.find_by_id(id)
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
rails_admin-0.0.1 spec/dummy_app/app/active_record/player.rb
obitum-rails_admin-0.0.5 spec/dummy_app/app/models/player.rb
drewda_rails_admin-0.0.1 spec/dummy_app/app/models/player.rb
obitum-rails_admin-0.0.4 spec/dummy_app/app/models/player.rb
obitum-rails_admin-0.0.3 spec/dummy_app/app/models/player.rb
obitum-rails_admin-0.0.2 spec/dummy_app/app/models/player.rb