I see from the log that
sql statement goes and updates
that record but status wont change to 1
so you see the sql statement in the log and the change in the database?
but any later request returns the wrong value?
or you see the sql statement and nothing changes in the db
or does any 'older' user object not reflect the changes? that would be
normal
This may be a bit subtle, but you might want to encapsulate the
concept of "approve" into the model. As it stands presently, you've
essentially mixed some business logic (what it means to approve a
user) into your controller. If you ever decide to change that concept
you're going to have to visit the controller... and every other place
that relies on User.status = 1 meaning "approved". You might consider
something like this:
class User
def approve
update_attributes(:status, 1)
end
def approved?
self.status==1
end
...
end
By doing this you've encapsulated the 'approved' concept into your
model and you can change your mind about the implementation later. For
example, maybe you want to use the acts_as_state_machine plugin and
introduce the idea of suspending the user. That would likely change
how you approve the user and how you test for it. With the code above
you can simply say...