Created
March 22, 2011 21:34
-
-
Save phildarnowsky/882127 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
>> phil@amanuensis:~/src/hengage$ heroku console | |
Ruby console for hengage.heroku.com | |
>> BadMessage | |
=> BadMessage(id: integer, phone_number: string, body: string, received_at: datetime, created_at: datetime, updated_at: datetime, is_new: boolean, on_watch_list: boolean, reply_count: integer) | |
# There's my new counter_cache column, reply_count. Let's initialize it to 0 on every record... | |
>> BadMessage.all.each {|bm| bm.reply_count = 0; bm.save!}; nil | |
=> nil | |
# How nice! No exceptions, it must have worked, right? | |
>> bm = BadMessage.first | |
=> #<BadMessage id: 7, phone_number: "[REDACTED]", body: "[REDACTED]", received_at: "2011-03-03 11:49:13", created_at: "2011-03-03 11:49:13", updated_at: "2011-03-22 21:31:06", is_new: nil, on_watch_list: nil, reply_count: nil> | |
# Well that's odd. | |
>> bm.reply_count = 0 | |
=> 0 | |
>> bm.valid? | |
=> true | |
>> bm.save | |
=> true | |
>> bm.reply_count | |
=> 0 | |
>> bm.reload.reply_count | |
=> nil | |
# FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFUUUUUUUUUUUUUUUUUUUUUUUUUUU... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment