I am upgrading Rails from 4 to 5 version. From one of my Model say entity model I am using Skip_callbacks for one method in after_create of the model, but still method is getting called which raises errors on save though skip_callbacks set to true
entity.rb
class Entity< ActiveRecord::Base
after_create :method, unless: :skip_callbacks
def method
#some code here
end
end
myspec_spec.rb
describe test do
before :each do
#some code here
@entity.save! skip_callbacks: true
end
end
Any suggestions will help me a lot for this issue.
Rails 4
Survey.skip_callback(:save, :before, :calculate_average)
Rails 5
Survey.skip_callback(:save, :before, :calculate_average, raise: false)
https://github.com/thoughtbot/factory_bot/issues/931
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With