Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edipofederle/d2551471a3212f1c44b539341dcb0ed0 to your computer and use it in GitHub Desktop.
Save edipofederle/d2551471a3212f1c44b539341dcb0ed0 to your computer and use it in GitHub Desktop.
Update check in time based on arrival time mandatory field
guest_arrival_time_id = ServiceField.where(name: 'guest_arrival_time').first.id
mandatory_fields_arrival_time = TaskField.where(service_field_id: guest_arrival_time_id).where.not(task_fields: {value: nil}).where.not(task_fields: {value: ""}).distinct
mandatory_fields_arrival_time.each do |arrival_time|
booking = arrival_time.task.booking
hour = Time.parse(arrival_time.value).hour
min = Time.parse(arrival_time.value).min
booking.check_in.change(hour: hour, min: min)
booking.save
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment