in rails when you register filters in abstract superclasses they come before the filters registered in the controller class. Say I wanted to execute a method called authenticate as a filter right at the end of the filter chain. The only way I can figure it out is to declare that before_filter as the last filter in all my controller classes (and there are many of them). Is there a way to declare this filter in the superclass and have it still be executed last? The reason I want it executed last is that the controller class might modify the authentication requirements just for that controller, and I want these modifications to be taken into account before the final authentication filter is called.
相关问题
- Question marks after images and js/css files in ra
- Using :remote => true with hover event
- Eager-loading association count with Arel (Rails 3
- Is there a way to remove IDV Tags from an AIFF fil
- Rails how to handle error and exceptions in model
相关文章
- 关于Asp.net Mvc Core重写Initialize方法的问题
- Right way to deploy Rails + Puma + Postgres app to
- Spring: controller inheritance using @Controller a
- AWS S3 in rails - how to set the s3_signature_vers
- how to call a active record named scope with a str
- How to add a JSON column in MySQL with Rails 5 Mig
- “No explicit conversion of Symbol into String” for
- form_for wrong number of arguments in rails 4
Use
prepend_before_filter
in your controller classes instead ofbefore_filter
orappend_before_filter
.Rails calls your ApplicationController first, before the local one... so you can do something like this (using your example):
In your Application controller you'll have your
before_filter
callback, and a corresponding method that gets called:In the controller for the resource type you're working with...
You can redefine / override
authenticate
You can even choose NOT to use your
authenticate
callback for some methods