Displaying 1 result from an estimated 1 matches for "check_an_activity_present".
2013 Mar 26
0
nested forms: use validate :some_method works in update mode only
...nverse_of: :timesheet
has_many :time_entries, through: :activities
accepts_nested_attributes_for :activities, allow_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(...