Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

show and edit are unauthorized on authorized (:manage) object #1031

@domachine

Description

@domachine

I've got a strange case where an object is reported as not accessible, but should be (according to accessible_by). I tested this using the following lines which should be self-descriptive (byebug in a controller):

Customer.accessible_by(current_ability, :show).count  # => 1
current_ability.can? :show, Customer.accessible_by(current_ability).first  # => false

In the show and the edit actions, this ends up in an unauthorized exception. I describe the permissions in the ability using the following code:

    if user
      return unless user.tags
      tags = user.tags.split(',')
      return if tags[0].empty?
      can :manage, Customer, tags: {name: tags}
    end

The customer model is simple:

class Customer < ActiveRecord::Base
  acts_as_taggable
end

I think this should be a working sample according to docs. Any suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions