Skip to content

Files

Latest commit

 

History

History
27 lines (19 loc) · 644 Bytes

Rails-ActiveRecordCallbacksOrder.md

File metadata and controls

27 lines (19 loc) · 644 Bytes

Pattern: Wrong Active Record callback order

Issue: -

Description

This rule checks that Active Record callbacks are declared in the order in which they will be executed.

Examples

# bad
class Person < ApplicationRecord
  after_commit :after_commit_callback
  before_validation :before_validation_callback
end

# good
class Person < ApplicationRecord
  before_validation :before_validation_callback
  after_commit :after_commit_callback
end

Further Reading