2016-09-14 3 views
0

私の問題は、モデルなしでリソースの能力を設定する方法を理解できないことです。今以来、私は、単一のAPIコントローラこの場合、プロファイルでモデルcancancanなしでAPIリソースの能力を設定する方法

class Api::V1::ProfilesController < Api::V1::BaseController 

    before_action :doorkeeper_authorize! 

    authorize_resource class: User 
    respond_to :json 

    api :GET, '/profiles', "This is index for all registered users except current user" 
    def index  
    render json: User.where.not(id: current_resource_owner.id) 
    end 

    api :GET, '/profiles/me', "This is current user profile's data" 
    def me  
    render json: current_resource_owner  
    end 

    protected 
    def current_resource_owner 
    @current_resource_owner ||= User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token 
    end 
end 

を持って、それが唯一のコントローラ(APIリソース)のモデルではありません。また、私はカンカン能力

can :me, User, id: user.id 
can **index????**, User, id: user.id 

を持っていることは、設定するのが難しいではなかったです私はすでにUsersControllerの設定された能力を持っているので、:インデックスアクションを持っていて、私はそれらを変更したくない)

私はこれを参照してください私の説明はそれほど単純ではない場合、私を許して(要求された場合、私はいくつかの追加の説明を書くことができます)と私の英語

答えて

1

のためにしてくださいだけで初心者だ:SO Question

チェックアウトこの行:authorize_resource :class => false

関連する問題