There anyway to apply a different filter to an action of a controller, than the parent controller has in Rails 3?
At the beginning of my controller I have filter_resource_access
which requires login for all actions on the controller.
开发者_开发问答However, for one action, I want to have a different authorization mechanism.
There anyway to have a different filter - perhaps a before_filter - for that action only without requiring the login that the parent filter requires ?
For filter_resource_access it looks like you have to change that out for custom before_filters and filter_access_to filters. See here search for 'filter_resource_access'.
You can specify which controller actions a filter applies to. You can either exclude or include actions like so:
before_filter :filter_action, :except => [:index, :edit]
before_filter :filter_action2, :only => [:index, :edit]
Click here for the associated Rails docs. Check out the 'Filter chain skipping' and 'Filter conditions' sections.
精彩评论