2011-12-29 5 views
1

before_filter私は、コントローラを次ていますは、機能についての混乱:

class CarsController < ApplicationController 
    autocomplete :user, :name 
    before_filter :require_user, :except => [:my_action] 

    def index 
    end 

    ... 

    def my_action 
    end 
end 

を私だけのユーザーがログインするために、このコントローラ内のすべてのアクションを見ることができるようにしたい - これは私が正常に動作します。しかし、私は皆のためづけしたいと思いアクションmy_action - 。また、ログインされていない人々のために

は私も:onlyパラメータで、:exceptパラメータで:before_filterを設定しようとしましたが、何も私を働きません...アプリはいつも私がログインするのを望んでいます...私はまだ間違っていますか?

EDIT:application_controller.rbからrequire_user

def require_no_user 
     logger.debug "ApplicationController::require_no_user" 
     if current_user 
     #store_location 
     flash[:warning] = "You must be logged out to access this page" 
     redirect_to account_url 
     return false 
     end 
    end 
+0

は 'require_user'ことは何ですか?どこから来たの? –

+0

元の投稿を更新しました。 – user984621

+1

これはちょうどタイプミスかもしれませんが、 'dev my_action'は' def my_action'でなければなりません...実際のコードにどのように入力されたのでしょうか? – Slick23

答えて

1

使用 skip_before_filter:require_user、:のみ=> [:my_action]