2
我成功地设置了decent_exposure gem,因为这个railscast。Rails 3使用current_user和decent_exposure访问范围
我想使用范围访问与current_user编辑/更新/创建操作,以避免通过比较对象的所有者与current_user检查权限。
控制器:
class CommentsController < ApplicationController
expose(:article)
expose(:comments) { article.comments }
expose(:comment)
def index
end
def new
end
def create
if comment.save
redirect_to comment.article, :notice => "Successfully created comment!"
else
render :new
end
end
end
我怎么能有decent_exposure这样的事情在我的编辑操作,例如:
@comment = current_user.comments.find(params[:id])
提前感谢!