can :manage, Comment, :user_id => @usr.id not working, but :user => {:id => @usr.id} works #502

Closed
swobspace opened this Issue Nov 1, 2011 · 5 comments

Projects

None yet

4 participants

@swobspace

The following definition didn't give the user @usr any rights:

can :manage, Comment, :user_id => @usr.id

But if I use the following definition

can :manage, Comment, :user => { :id => @usr.id }

all works as expected. As the wiki page "Defining Abilities" mentioned, both should be equivalent.

I'm using Rails 3.1.1, cancan 1.6.7 and ruby 1.8.7.

wob

@yangman-tutu

what is its role?
i use it in my app, had an exception:
RuntimeError in RailsAdmin::MainController#new

Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id

@Gimi
Collaborator
Gimi commented May 12, 2012

I've just tested it in a new Rails 3.1.1 application with cancan 1.6.7 and ruby 1.8.7, and didn't have this problem. Are you still having this problem? If you are, would you please offer more details?

@andhapp
Collaborator
andhapp commented May 17, 2012

@swobspace: I am going to close this issue for now. If you still have this issue, please comment here and it'll be reopened for further discussion/investigation.

@andhapp andhapp closed this May 17, 2012
@yangman-tutu

i have fixed it,can i use like this :manage, Comment, :user_id => user.id
cheerly!

@swobspace

@Gimi @andhapp: I can't test it at the moment, I switched to Rails 3.2 with the patch from jpascal #577 to use rails 3.2 mass assignment stuff., so I'm not on the master branch.

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