0

Ruby on rails 3.1 で declarative_authorization を使用しています。

グループには多くのアルバム (groupalbum) があり、グループは 1 人のユーザーによって作成されます (グループ テーブルの外部キーの user_id)。グループの所有者だけがアルバムを作成できます。

ここに私の authorization_rules.rb があります:

has_permission_on [:group_albums], :to => [:create] do
    if_attribute :group =>  { :user => is_in { user.groups } }
end

ここに私の GroupAlbumsControler があります:

class GroupAlbumsController < ApplicationController
    before_filter :set_group_album_from_params, :only => :show
    before_filter :set_group_album_new, :only => [:index, :new]
    filter_access_to :all, :attribute_check => true
    (...)
end

しかし、うまくいきません:

You are not allowed to access this action.

グループの所有者でログインしている場合でも。

私の間違いはどこですか?

4

1 に答える 1

0

これが機能しない理由はたくさんあります。

:index と :new を権限に追加しましたか?

privileges do
  privilege :manage, :includes => [:create, :read, :update, :delete]
  privilege :read, :includes => [:index, :show]
  privilege :create, :includes => :new
  privilege :update, :includes => :edit
  privilege :delete, :includes => :destroy
end

現在のユーザーの :group_albums に対する読み取り権限はありますか?

has_permission_on [:group_albums], :to => [:create, :read] do
    if_attribute :group =>  { :user => is_in { user.groups } }
end

どのアクションを呼び出しますか?

于 2013-05-15T13:32:44.500 に答える