Sha256: 36d85ccb192beceef25f77aace16390bfe1fe68429ba3bd2ce191d1cf897f8d2

Contents?: true

Size: 499 Bytes

Versions: 3

Compression:

Stored size: 499 Bytes

Contents

class Player < Sequel::Model
  set_primary_key(:id)
  plugin(:timestamps, :update_on_create => true)
  plugin(:validation_helpers)

  many_to_one(:team)
  one_to_one(:draft)

  self.raise_on_save_failure = false
  self.raise_on_typecast_failure = false
  def validate
    validates_numeric(:number, :only_integer => true)
    validates_unique(:number, :message => "There is already a player with that number on this team") do |dataset|
      dataset.where("team_id = ?", team_id)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
merb-admin-0.8.8 spec/models/sequel/player.rb
merb-admin-0.8.7 spec/models/sequel/player.rb
merb-admin-0.8.6 spec/models/sequel/player.rb