我對具有3個用戶類別的應用程序(公司,客戶和管理員)使用Rails 3.2,Devise和Cancan。找不到current_user方法(Rails,Devise,Cancan)
我的問題是,我得到這個:
undefined local variable or method `current_user' for #<HomeController:0xb4fd217c>
在HomeController中我有:
class HomeController < ApplicationController
before_filter :authenticate_customer!
load_and_authorize_resource :class => false
def index
render 'index'
end
end
而且,在視圖中:
- content_for :title, 'Home'
= link_to('Logout', destroy_customer_session_path, :method => :delete)
我不是要求CURRENT_USER任何地方在我的代碼中。
任何想法?
你的「authenticate_customer!」是什麼?方法看起來像? – cpuguy83 2013-03-16 00:49:55
這是從設計,我沒有實現它。 – cgf 2013-03-16 01:06:37
您是使用CanCan還是其他一些與Devise交互的寶石?我特別提到了CanCan,因爲您可能需要根據[此GitHub問題](https://github.com/ryanb/cancan/issues/598)在「ApplicationController」中創建一個'current_ability'方法。 – 2013-03-16 01:15:11