Skip to content

Instantly share code, notes, and snippets.

@mh-github
Created June 1, 2017 19:15
Show Gist options
  • Select an option

  • Save mh-github/b0384aa39a325123b6b2c7e4dd92c2c8 to your computer and use it in GitHub Desktop.

Select an option

Save mh-github/b0384aa39a325123b6b2c7e4dd92c2c8 to your computer and use it in GitHub Desktop.
class Travel < ActiveRecord::Base
belongs_to :expenses_claim
has_many :travel_expenses
accepts_nested_attributes_for :travel_expenses, allow_destroy: true
validates :end_date, presence: true, date: { :after_or_equal_to => :start_date, message: "must be after or equal to start date."}
validates :end_date, presence: true, date: { :before_or_equal_to => Proc.new { Time.now }, message: "must be today #{(Date.today).to_s} or before." }, on: :create
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment