I have a question on updating records. I have this User model that
requires a password in order to save. In the database there is the
password hash and salt so I don’t save the password. However, when I
retrieve a user record and try to update using the save function it
would not update. I assume because the password attribute is
automatically set to nil when retrieving a record.
Since I cannot use save, I tried the update method. For example if I
type on the console
This worked but I realized that the update method is not part of the
rails API. There are only four update type methods in
ActiveRecord::Base, update(:id, attributes), update_all(updates,
conditions=nil), update_attribute, and update_attributes.
So my questions are
- Why does update (without any arguments) work since it is not part
of the API documentation?
- Why does update_attributes not work in updating my user record but
update_attribute works for one field?
- Do you know a good way if I want to update my User record if I want
to update more than one field? I don’t mind using the update method w/
o parameters but I wonder if it is deprecated.