我有設計+創建一個腳手架「房子」,我希望用戶只能編輯自己的房子。自定義current_user設計+ Mongoid
這是我houses_controller:
def authenticate_owner!
@house = house.find(params[:id])
if user_signed_in? && current_user.email == @house.user.email
return true
end
redirect_to root_path, :notice => "You must have permission to access this category."
return false
end
我有太多的代碼在頂部houses_controller:
before_filter :authenticate_owner!
skip_before_filter :authenticate_owner! , :only => [:show, :index, :new]
,但沒有工作,總是顯示消息:
「您必須具有訪問此類別的權限。「
我如何獲得創建腳手架的用戶並將其與註冊的用戶進行比較?
您發佈的代碼不完整 – Tilo