【发布时间】:2011-10-03 16:18:58
【问题描述】:
我已经设计 + 一个脚手架“房子”,我希望用户只能编辑你自己的房子。
这是我的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]
但不工作,总是显示消息:
“您必须有权访问此类别。”
如何获取创建脚手架的用户并将其与注册用户进行比较?
【问题讨论】:
-
你贴的代码不完整
标签: ruby-on-rails devise mongoid