Skip to content

Instantly share code, notes, and snippets.

@cirode
Created December 1, 2017 02:15
Show Gist options
  • Save cirode/1b679bb5e5b03f9ca301149f4b36e506 to your computer and use it in GitHub Desktop.
Save cirode/1b679bb5e5b03f9ca301149f4b36e506 to your computer and use it in GitHub Desktop.
Hooroo: Cleansing Operation For Maximum Stays
Offer.includes(room_type: :property).where('properties.status=? and offers.default_maximum_stay=?', 'published',1).find_each do |offer|
offer.default_maximum_stay = nil
offer.rates.where('night_of >= ? and maximum_stay=?', Date.today,1).find_each do |rate|
rate.maximum_stay = nil
rate.save!
end
offer.save!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment