Skip to content

Instantly share code, notes, and snippets.

@exviva
Created January 25, 2017 02:11
Show Gist options
  • Save exviva/ca228f4c853d8087d6622d1c34d0df6c to your computer and use it in GitHub Desktop.
Save exviva/ca228f4c853d8087d6622d1c34d0df6c to your computer and use it in GitHub Desktop.
Shameless writing
# All index fields are required,
# the rest is the schemaless content
rate = Rate.put(hotel_id: 1,
room_type: '1 bed',
check_in_date: Date.today,
discount_type: 'geo',
net_price: 120.0) # potentially ~20 fields
rate[:hotel_id] # => 1
rate[:net_price] # => 120.0
rate.ref_key # => 0 # that's the version
rate[:net_price] = 130.0
rate.save
rate.ref_key # => 1
# Or:
rate.update(net_price: 140.0)
rate.ref_key # => 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment