0

クエリ書き換え機能を使用してモデルレベルで宣言型承認を使用して、次のようなhtml選択オプションをフィルタリングしようとしています:

モデル:

class TreatmentClinic < ActiveRecord::Base

    def self.filtered_by_user_context
        with_permissions_to(:read)
    end
end

表示 (新しいアクション):

<%= form_for(@something) do |f| %>

      <%= f.select :id, TreatmentClinic.filtered_by_user_context.collect {|t| [ t.name, t.id ] }, {:include_blank => 'Please select'} %>

      <%= f.submit %>

<% end %>

authentication_roles.rb:

role :some_role do
    has_permission_on :treatment_clinics do
        to :read
        if_attribute :id => '1'
    end
end

私はソーサリーを使用しており、宣言型承認でうまく機能しています。宣言的な承認権限は、コントローラーとビューのレベルで正常に機能していますが、上記の選択で次のエラーがスローされます。

 No matching rules found for [:read] for #<Authorization::AnonymousUser:0x007fd257c00090 @role_symbols=[:guest]> (roles [:guest], privileges [:read, :manage], context :treatment_clinics).

何か案は?

4

1 に答える 1