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])
提前感謝!