I have installed the RailsTutorial sample app(the twitter like application) and am trying to understand why the following piece of console code does not update the database
I know this is an old post, but hopefully this might help someone going through this tutorial in the future.
As the accepted answer expresses, this is due to validations which are not being satisfied. I ran into this issue as well and found that another workaround is to use the update_attribute method on the user object. For example, if you want to update the name field of a user object and have it automatically save to the database, without having to touch the virtual password and password_confirmation fields, use the following:
user.update_attribute(:name, "larry")
This will update the name field only and save it to the database (no need to call the save method), without having to touch the password and password_confirmation fields.