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)
我认为最友好的Rails方式是prepend_before_filter在SessionsController中使用:
class SessionsController < ApplicationController
prepend_before_filter :run_first
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
675 次 |
| 最近记录: |