Skip to content

Instantly share code, notes, and snippets.

@tdouce
Created January 31, 2012 03:31
Show Gist options
  • Save tdouce/1708577 to your computer and use it in GitHub Desktop.
Save tdouce/1708577 to your computer and use it in GitHub Desktop.
class Individual < ActiveRecord::Base
#attr_writer :train
#attr_accessor :trained
#attr_accessible :trained
#attr_protected :trained
before_update :untrain
validates :height, :presence => true, :numericality => true
validates :weight, :presence => true, :numericality => true
validates :gender, :presence => true
MALE = 'Male'
FEMALE = 'Female'
MALEPROB = 0.5
FEMALEPROB = 0.5
GENDERS = [ MALE, FEMALE ]
scope :untrained, Individual.where( :trained => false )
scope :gender, lambda { |gender| where("gender = ?", gender ) }
private
def untrain
#self.update_attributes( :trained => false )
self.trained = false
#a.save
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment