2013-10-16 26 views
0

是否有可能我不僅爲before_filter定義了一個動作,而且還爲動作的控制器定義了一個動作?我想把的before_filter方法到我application_controller但是當我如定義有:不僅爲before_filter定義動作,而且還控制器

before_filter :authorize, except: [:index] 

所有控制器都受到影響的是有一個索引行動! 我想WIRTE類似的東西:

before_filter :authorize, except: [user#index] 

感謝

回答

1

你不能做你所要求的。你可以做的是

class ApplicationController < ActionController::Base 
    before_filter :authorize 
    ... 
end 


class UsersController < ApplicationController 
    skip_before_filter :authorize, :only => [:index] 
    ... 
end 
0

爲什麼不把過濾器前,在你的users_controller?

class UsersController < ApplicationController 
    before_filter :authorize, except: [:index] 
    ... 
end 
+0

但它是我的意圖把它放到應用程序控制器,以節省時間和工作 –

相關問題