<model>.update(...) not calling before_update callback

Hi,

I’m doing a <model_name>.update(…) but I’m noticing that my
before_update callback is not being called. If I do a find and then a
save!, I notice that it is called. The problem with a find and save in
my case is that I’m not able to set all my attributes in one shot by
saving params[“user”] and since I can’t do this, my overloaded equality
def: user=(…) in my model does not get called which I need to call.
Any help on either of these methods would be great!.

Thanks.

Any thoughts on this one guys? How do I reinitialize an already
initialized model object in my controller in one shot rather than
manually initializing each attribute? In other words, I do a find like
so:

user = User.find(id)

Now I want to reinitialize the user object by using the params[“user”]

but I’d like to intialize it in a way that calls my model’s equality
operator to do some sepecial initializations defined as so:

In my model

def user=(user)

end


I need to somehow invoke the after_* and before_* callbacks and these
apparently don’t get invoked if I do an update like so:
user.update(…). It seems like I must do a user.save! to invoke them.

Thanks,

Saureen.

SAm wrote:

Hi,

I’m doing a <model_name>.update(…) but I’m noticing that my
before_update callback is not being called. If I do a find and then a
save!, I notice that it is called. The problem with a find and save in
my case is that I’m not able to set all my attributes in one shot by
saving params[“user”] and since I can’t do this, my overloaded equality
def: user=(…) in my model does not get called which I need to call.
Any help on either of these methods would be great!.

Thanks.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs