简体   繁体   中英

ActiveAdmin Sortable and Cancancan Ability

I am building a Rails application using ActiveAdmin and ActiveAdmin Sortable gem to change posts order.

I haven't been able to figure out how to authorize this action in my Cancancan ability.rb file.
If I use can :manage, Post it works but I don't want to give all permissions, only some.
Which action should be used in my Ability file to only allow ordering ?

Thanks for your help !

My project :

When using ActiveAdmin Sortable gem with a resource, an action

:sort

will be added to the controller for your Post . I think you can use

can(:sort, Post)

in the ability.rb file. You may have to conditionally hide/show the sortable handle column. I think you can do it this way in the index part:

index do
  sortable_handle_column if can?(:sort, Post)
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM