将before_filter方法添加到rails 3中列表的末尾

gil*_*las 6 ruby-on-rails ruby-on-rails-3

我在application_controller中有before_filter:方法,我希望这个方法在继承类中的before_filter方法之后运行.

我该怎么做?

class ApplicationController < ActionController::Base
  protect_from_forgery

  before_filter :run_second
end

class SessionsController < ApplicationController
  before_filter :run_first
end
Run Code Online (Sandbox Code Playgroud)

cor*_*ard 6

我认为最友好的Rails方式是prepend_before_filter在SessionsController中使用:

class SessionsController < ApplicationController
  prepend_before_filter :run_first
end
Run Code Online (Sandbox Code Playgroud)