Displaying 1 result from an estimated 1 matches for "time_entries_by_date".
2013 Mar 26
0
nested forms: use validate :some_method works in update mode only
...low_destroy: true
validates :user_id, presence: true
validates :status, presence: true, inclusion: {in: STATUS_VALUES}
validate :maximum_worktime_per_day
after_update :check_an_activity_present
after_initialize :init_working_week
..
private
def maximum_worktime_per_day
time_entries_by_date = time_entries.group_by(&:workdate)
time_entries_by_date.each do |key, value|
errors[:base] << "Maximum daily time should not exceed 1 day" if
value.map(&:worktime).inject(:+) > 1
break
end
end
As I could see the output in the console, wh...