Created
April 26, 2012 16:19
-
-
Save kenton/2500699 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# saving tiers to the DB | |
> market = OndemandMarket.first | |
> market.pricing_tiers = { :first_five_minutes => 3.0, :second_five_minutes => 2.5, :additional_minutes => 1.0 } | |
> market.save | |
# pulling tiers from the DB | |
> market.pricing_tiers | |
{ :first_five_minutes => 3.0, :second_five_minutes => 2.5, :additional_minutes => 1.0 } | |
# to update rows on a table | |
> OndemandMarket.all.each do |m| | |
m.pricing_tiers = {:first_five_minutes => 3.0, :second_five_minutes => 2.5, :additional_minutes => 1.0} | |
m.ten_mile_multiplier = 1.5 | |
m.twenty_mile_multiplier = 1.75 | |
m.time_factor = 2.0 | |
m.save | |
end | |
# update one row at a time | |
> m = OndemandMarket.find(1) | |
# replace the "1" with the ID for whatever record you want to update | |
> m.update_attributes!(:pricing_tiers => {:first_five_minutes => 3.0, :second_five_minutes => 2.5, :additional_minutes => 1.0}, :ten_mile_multiplier => 1.5, :twenty_mile_multiplier => 1.75, :time_factor => 2.0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment