我的 application_controller 中有 before_filter :method,我希望这个方法在继承类中的 before_filter 方法之后运行。
我该怎么做?
例子
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :run_second
end
class SessionsController < ApplicationController
before_filter :run_first
end
最佳答案
我认为最适合 Rails 的方法是使用 prepend_before_filter
在你的 SessionsController 中:
class SessionsController < ApplicationController
prepend_before_filter :run_first
end
关于ruby-on-rails - 将 before_filter 方法添加到 rails 3 中列表的末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6399413/