Skip to content

Instantly share code, notes, and snippets.

@edipofederle
Last active November 19, 2018 11:41
Show Gist options
  • Save edipofederle/33188243fc0da9aaa15f6d03341e4547 to your computer and use it in GitHub Desktop.
Save edipofederle/33188243fc0da9aaa15f6d03341e4547 to your computer and use it in GitHub Desktop.
# for future bookings
ActiveRecord::Base.logger.level = 1 # disable query logs
bookings = Booking.where('check_out >= ?', Time.now);nil
bookings.each do |booking|
city = booking&.property&.city
new_value = booking.decorate.check_out.change(hour: 11, min: 0)
booking.guest_check_out_at = city ? city.utc_time(new_value) : new_value
PaperTrail.whodunnit('Edipo F: set initial value for guest_check_out_at') do
booking.save(validate: false)
end
end;nil
# for past bookings (make sense ?) - leave it as is
ActiveRecord::Base.logger.level = 1 # disable query logs
bookings = Booking.where('check_out < ?', Time.now).where(guest_check_out_at: nil);nil
bookings.each do |booking|
booking.guest_check_out_at = booking.check_out.change(hour: 11)
booking.save(validate: false);nil
end
@edipofederle
Copy link
Author

ok

@Irostovsky
Copy link

city = booking&.property&.city
new_value = booking.decorate.check_out.change(hour: 11, min: 0)
booking.guest_check_out_at = city ? city.utc_time(new_value) : new_value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment