2

decent_exposure 젬을 railscast으로 성공적으로 설정했습니다.레일 3 - current_user 및 decent_exposure를 사용하여 범위 액세스

개체 소유자를 current_user와 비교하여 권한을 확인하지 않으려면 편집/업데이트/만들기 작업에 current_user와 함께 범위 액세스를 사용하고 싶습니다.

컨트롤러 : 내가 예를 들어 내 편집 액션이 같은 decent_exposure의 뭔가가 어떻게

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 

: 사전에

@comment = current_user.comments.find(params[:id]) 

감사합니다!

답변

1

난 당신이 할 수 있다고 생각 :

가 노출 (: user_comments를) {current_user.comments}

노출 (: USER_COMMENT)

가 USER_COMMENT이 current_user.comments로 범위해야하고 사용할 것 user_comment가보기에 사용됩니다.