Ruby on Rails
Thursday, October 25, 2012
On Tuesday, 23 October 2012 05:09:50 UTC-4, Peter Hickman wrote:
This is for Rails 3.1.1
I have a field called last_seen in a model. This field will be updated
when the something about the record is seen in the real world (don't
worry about this part)
So I go x.update_attribute(:last_seen, Time.now) and the following happens is
UPDATE "blah" SET "last_seen" = '2012-10-23 08:57:46.179288',
"updated_at" = '2012-10-23 08:57:54.872808' WHERE "blah"."id" = 2673
Now, just for this one attribute, I would like the updated_at field to
be unmolested. Is there some way of updating the last_seen field
without ActiveRecord updating the updated_at field?
update_column will do exactly what you're looking for, and has the advantage of not being on the short list to go away in Rails 4.1 like update_attribute. :)
--Matt Jones
-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/iv8sH65CLXwJ.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment