This will work for Rails 3.x onwords Model.skip_callback(“create”,:after,:trigger_my_method) in the above line ‘create’ and ‘after’ represents callback name so it represents ‘after_create’ callback, and the callback method is ‘trigger_my_method’, so totally the above line skips below callback after_create :trigger_my_method You can skip validations just by passing :validate => false as parameter to save method Model.save(:validate => false) As before skipping callback, you can reset same callback for reset by below ling Model.set_callback(“create”,:after,:trigger_my_method) This line will reset the below callback after_create :trigger_my_method Example:- Skip callback and validation and rest the skiped callback Post.skip_callback(“create”,:after,:trigger_my_method) post=Post.new(params[:post]) post.save(:validate => false) Post.set_callback(“create”,:after,:trigger_my_method)
While Robolectric met a lot of my requirements I had the need for a powerful mocking framework and Moviles android decided to use PowerMock(ito). It's a really powerful framework but I wasn't able to use it together with Robolectric since both do a lot of classloader and byte code transformation magic.
ReplyDelete