开发者

add before_filter method to the end of the list in rails 3

开发者 https://www.devze.com 2023-03-14 02:18 出处:网络
I have before_filter :method in my application_controller and I want thi开发者_开发技巧s method to run after the before_filter methods in inherit class.

I have before_filter :method in my application_controller and I want thi开发者_开发技巧s method to run after the before_filter methods in inherit class.

how can I do it?

example

class ApplicationController < ActionController::Base
  protect_from_forgery

  before_filter :run_second
end

class SessionsController < ApplicationController
  before_filter :run_first
end


I think the most Rails-friendly way of doing this would be to use prepend_before_filter in your SessionsController:

class SessionsController < ApplicationController
  prepend_before_filter :run_first
end
0

精彩评论

暂无评论...
验证码 换一张
取 消