views:

595

answers:

3

I have model like this

class Vote < ActiveRecord::Base  
    after_save :add_points_to_user

    .....
end

Is it possible to somehow force model to skip calling add_points_to_user when saved? Possibly something like ActiveRecord#delete vs ActiveRecord#destroy?

+2  A: 

vote.save(false)

Aaron Qian
yup, I f*cked up... oops
Aaron Qian
Stanislav is right
Aaron Qian
+7  A: 

The accepted answer is not correct.

On .save(false) we only miss validations but not callbacks.

It this case add_points_to_user will be executed too.

As mentioned , you can use these:

Model.send(:create_without_callbacks)
Model.send(:update_without_callbacks)
Stanislav
A: 

Use AR methods which don't use callbacks: Skipping Callbacks.

splattael