NPE in association_joins when using accessible_by #66

Closed
jrallison opened this Issue May 5, 2010 · 0 comments

1 participant

@jrallison

My ability class basically looks something like:

class Ability
  include CanCan::Ability

  def initialize(user)
    if user.admin?
      can :manage, :all
    else
      can :manage, Group, :users => { :id => user.id }
    end
  end
end

In my controller, I find groups like:

Group.accessible_by(current_ability)

If I'm logged in as a non-admin, it works fine. However, when I'm an admin, association_joins assumes conditions are defined. This ends in badness as can :manage, :all doesn't define any conditions.

I've fixed it in my fork... http://github.com/challengepost/cancan/commit/487ce92632386461adf7ab93e1ae59bb856daad1

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment