Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: f45d986bee
Fetching contributors…

Cannot retrieve contributors at this time

30 lines (25 sloc) 0.783 kb
class Mastery < ActiveRecord::Base
belongs_to :crop
belongs_to :farm
default_scope order('market_order')
after_initialize :set_defaults
validates_numericality_of :stars,
:greater_than_or_equal_to => 0,
:less_than_or_equal_to => 3,
:only_integer => true
#TODO: how come this doesn't work?
# :inclusion => { :in => [0, 1, 2, 3 ] }
# :inclusion => { :in => %w{0 1 2 3} }
validates_numericality_of :additional_harvests,
:greater_than_or_equal_to => 0,
:only_integer => true
def set_defaults
return unless new_record?
self.stars ||= 0
self.additional_harvests ||= 0
self.market_order = crop.market_order
end
def Mastery.one_for_each_crop
Crop.all.collect { |crop| Mastery.new(:crop => crop) }
end
end
Jump to Line
Something went wrong with that request. Please try again.