Defining one callback several times in the same class behaves different in ActiveRecord and ResourceController.
While in ActiveRecord the callbacks are enqueued, they overwrite each other in ResourceController.
class Post < ActiveRecord::Base
does 'post/behavior'
before_validation :do_something
end
module Post::BehaviorTrait
as_trait do
before_validation :do_something_else
end
end
do_something_else
and do_something
are executed before validation in exactly this order
class PostController
include ResourceController::Controller
does 'post_controller/behavior'
index.before { do_something }
end
module PostController::BehaviorTrait
as_trait do
index.before { do_something_else }
end
end
Only do_something
is executed before index because the callback defined in the trait is overwritten.