Sha256: e2b08fe72e98cb91ffc8fbb4b0d2c395756a2667916ff0123d17f37a9fd3ec2b

Contents?: true

Size: 858 Bytes

Versions: 3

Compression:

Stored size: 858 Bytes

Contents

# coding: utf-8

class Team < ActiveRecord::Base
  has_many :players, -> { order :id }, inverse_of: :team
  has_and_belongs_to_many :fans
  has_many :comments, as: :commentable

  validates_numericality_of :division_id, only_integer: true
  validates_presence_of :manager
  validates_numericality_of :founded, only_integer: true
  validates_numericality_of :wins, only_integer: true
  validates_numericality_of :losses, only_integer: true
  validates_numericality_of :win_percentage
  validates_numericality_of :revenue, allow_nil: true
  belongs_to :division

  def player_names_truncated
    players.collect { |p| p.name }.join(', ')[0..32]
  end

  def color_enum
    ['white', 'black', 'red', 'green', 'blu<e>é']
  end

  scope :green, -> { where(color: 'red') }
  scope :red, -> { where(color: 'red') }
  scope :white, -> { where(color: 'white') }
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_admin-0.6.3 spec/dummy_app/app/active_record/team.rb
rails_admin-0.6.2 spec/dummy_app/app/active_record/team.rb
rails_admin-0.6.1 spec/dummy_app/app/active_record/team.rb