dev-resources.site
for different kinds of informations.
What is the ordering of Ruby on Rails controller filters?
Published at
8/10/2021
Categories
rails
shopifyapp
Author
Dr Nic Williams
Some of my application's controllers are a blend of modules from other people's Rubygems, such as ShopifyApp library. They inject before and after action filters around my actions. Sometimes they abort the request and redirect somewhere else. I wanted to know what filters were being invoked and in what order:
class ProductsController < AuthenticatedController
def index
__callbacks[:process_action].map { |c| [c.kind, c.instance_variable_get(:"@key")] }
end
end
The output was like:
[
[:around, 82000],
[:before, :set_shop_host],
[:before, :redirect_to_splash_page],
[:before, :set_locale],
[:after, :set_test_cookie],
[:before, :verify_authenticity_token],
[:after, :verify_same_origin_request],
[:after, :set_esdk_headers],
[:before, :login_again_if_different_user_or_shop],
[:around, :activate_shopify_session],
[:before, :set_shop_origin]
]
Articles
8 articles in total
Broadcasting custom Turbo actions like set_title, morph, and more
read article
Friendly IDs for Ruby on Rails
read article
./bin/commits-since-last-production-deploy
read article
What is my current Tailwind CSS breakpoint?
read article
How to display Admin-only links with CSS
read article
What is the ordering of Ruby on Rails controller filters?
currently reading
How to isolate your Rails blobs in subfolders
read article
Automatically sorting your Tailwind CSS class names
read article
Featured ones: