if_attribute fails on server but not Rails console

101 views
Skip to first unread message

Chris

unread,
Apr 10, 2013, 2:44:09 PM4/10/13
to declarative_...@googlegroups.com
I have an 'Application' model which has_many owners through application_owner_assignments as well as a similar relation of has_many operators through application_operator_assignments.

I wrote the following permission to give read access to anybody who owns or operates an application:
    # Operators can read applications
    has_permission_on :applications, :to => :read do
      if_attribute :operators => contains { user }, :context => :applications
    end
    # Owners can read and update their own applications
    has_permission_on :applications, :to => [:read, :update] do
      if_attribute :owners => contains { user }, :context => :applications
    end

In the rails console, Application.with_permissions_to(:read) works perfectly.

In the development server, it fails, seeming to fetch the correct records but then the if_attribtue check tries to look for the 'operators' method against a ActiveRecord::Relation .

Is this a bug?

Chris

unread,
Apr 10, 2013, 2:58:36 PM4/10/13
to declarative_...@googlegroups.com
The error seems to have been caused by current_user lacking the 'index' permission on that controller/action.

Why would I get an error about an ActiveRecord::Relation if they lack permissions for that view?
Reply all
Reply to author
Forward
0 new messages