Forum: Ruby on Rails Updating only some of the fields of a table.

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
DDudde (Guest)
on 2006-03-01 01:37
It's not clear to me how to save data to only some of the fields of a
table. To update individual fields I can do something like this:

@foo = = "hello!"
@foo.anotherbar = "hello again"

However what if I only want to save the field "anotherbar" and don't
want the final insert or save query to contain the field "bar" at all?
If I do somethig like this...

@foo =
@foo.anotherbar = "hello again" expected, rails still tries to create an INSERT query with the
"bar" record, giving it a NULL value. Any idea how I could ommit the
"other" field completely?
DDudde (Guest)
on 2006-03-01 03:33
Never mind. I was doing something completely wrong. It seems to work
fine as is.
This topic is locked and can not be replied to.