2013-01-17 27 views
0

我安裝了Devise和Cancan。我的用戶具有以下選項的角色super_admin:安裝devise和cancan後不能刪除對象

def initialize(user) 
    user ||= User.new # guest user 
    can :manage, :all 
end 

除刪除元素外,其他所有方法都行得通。當我試圖刪除對象:

<%= link_to 'Destroy', place, :method => :delete, :data => { :confirm => 'Are you sure?' } %> 

它不斷記錄了我,並重定向到sign_in頁

我的類看起來像:

class PlacesController < ApplicationController 
    before_filter :authenticate_user! 
    load_and_authorize_resource 
+0

如果您在複製此行爲時添加日誌文件的相關部分,將會有所幫助。在點擊「銷燬鏈接」之前,使用'> log/development.log'命令清空日誌文件,然後在單擊鏈接後獲取文件的完整輸出。 –

回答

0

好吧,我想通了。

我的佈局文件沒得authenticity_token標籤

<%= csrf_meta_tag %> 

所以POST和DELETE請求不能被驗證。