Sha256: fc40a89d9456181368ba2703316e753d883ee35d29f35c8d68c936bfe210029b
Contents?: true
Size: 686 Bytes
Versions: 2
Compression:
Stored size: 686 Bytes
Contents
class Player < ActiveRecord::Base belongs_to :team, :inverse_of => :players has_one :draft, :dependent => :destroy has_many :comments, :as => :commentable 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 before_destroy :destroy_hook def destroy_hook; end def draft_id self.draft.try :id end def draft_id=(id) self.draft = Draft.find_by_id(id) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails_admin-0.6.0 | spec/dummy_app/app/active_record/player.rb |
rails_admin-0.5.0 | spec/dummy_app/app/active_record/player.rb |