NoamB/sorcery — pull request #279 by pupeno (2012-05-02 13:03:14+00:00)
Title: Do not call save on the model when only a few attributes are being changed.

Hello,

In our user model we have a couple of serialized attributes and Rails apparently always saves serialized attributes when calling save because it cannot keep track of whether they are dirty or not (I think). This meant that in many requests that used Sorcery, we end up doing a rather big update to a database. Also, we have some after filters that were unexpectedly run due to Sorcery calling save on the model.

We noticed this didn't always happen because some modules of Sorcery use update_single_attribute. We wrote a similar but more generic update_many_attributes and made sure it is used instead of save everywhere where it makes sense (it doesn't when changing the password or creating a new user).

We did this change on top of the last stable version (v0.7.11) but the difference to the current master is small and documented in the commit.

We ran all the tests before and after this commit and we got the same amount of failures (everything passed but three oauth related tests). We also made sure we ran all the touched lines by manual testing from our application that is using Sorcery, except the mongo implementation of update_many_attributes, that is untested.

We did this change pair-programming, @dmagliola and I.