class Team
	include Mongoid::Document
	include Mongoid::Timestamps

	field :number, type: Integer

	field :location, type: String
	field :name, type: String

	has_many :participations
	has_many :records

	def self.number(team_number)
		raise ArgumentError, "Must supply a team number!" unless team_number.is_a?(Integer)

		return self.where(number: team_number).first
	end

	validates :number, :location, :name, presence: true
	validates :number, uniqueness: true

	# alias_method works by default solely on instance
	# methods, so change context to the metaclass of
	# Team and do aliasing there.
	class << self
		alias_method :with_number, :number
		alias_method :that_has_number, :number
	end
end

class Team
	include Mongoid::Document
	include Mongoid::Timestamps

	field :number, type: Integer

	field :location, type: String
	field :name, type: String

	has_many :participations
	has_many :records

	def self.number(team_number)
		# Team.find_by number: team_number
		find_by number: team_number
	end

	validates :number, :location, :name, presence: true
	validates :number, uniqueness: true

	# alias_method works by default solely on instance
	# methods, so change context to the metaclass of
	# Team and do aliasing there.
	class << self
		alias_method :with_number, :number
		alias_method :that_has_number, :number
	end
end

Use find_by instead of where
Use find_by instead of where

We are getting one element, so we might as well use a function that
retrieves one element.
This is comparable to using `find` instead of `select.first`.
Sorry for being a jerk.
