railsadminteam / rails_admin

RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
MIT License
7.88k stars 2.25k forks source link

Generate correct user edit url #3531

Closed fuegas closed 2 years ago

fuegas commented 2 years ago

The current generated URL looks like /user?action_name=edit&id=42. However, if you use an authorization gem like cancancan this url requires the capability :index. If you only allow a user to edit itself, for example can :edit, ::User, id: user.id, the current URL would cause an Error to be thrown ( CanCan::AccessDenied ).

When we change action_name to action, the generated URL becomes /user/42/edit which matches the capability can :edit, ::User, id: user.id.

Fixes #3514.

coveralls commented 2 years ago

Coverage Status

Coverage decreased (-0.2%) to 95.889% when pulling 97d21722241dbfc78b8f516588fee9937c491a92 on fuegas:user-edit-url into ce1bb5a1c166b62412e4032b2d1f798297a7c289 on railsadminteam:master.

mshibuya commented 2 years ago

Thanks for the fix!