anthony
anthony

Reputation: 650

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:

Upvotes: 0

Views: 190

Answers (1)

Sjors Branderhorst
Sjors Branderhorst

Reputation: 2182

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

Upvotes: 1

Related Questions