Skip to content

Instantly share code, notes, and snippets.

@enricostano
Created August 4, 2012 13:25
Show Gist options
  • Save enricostano/3257741 to your computer and use it in GitHub Desktop.
Save enricostano/3257741 to your computer and use it in GitHub Desktop.
Project class
class Project < ActiveRecord::Base
attr_accessible :name, :start, :stop, :institution_id
belongs_to :institution
validates :name, :start, :stop, :institution, :presence => true
validate :start_before_stop_date
def start_before_stop_date
if self.start && self.stop && self.start >= self.stop
self.errors.add :start, ' deve essere prima di stop'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment