简体   繁体   English

ActiveAdmin可排序和Cancancan能力

[英]ActiveAdmin Sortable and Cancancan Ability

I am building a Rails application using ActiveAdmin and ActiveAdmin Sortable gem to change posts order. 我正在使用ActiveAdminActiveAdmin Sortable gem构建Rails应用程序以更改发布顺序。

I haven't been able to figure out how to authorize this action in my Cancancan ability.rb file. 我一直无法弄清楚如何授权我Cancancan ability.rb文件这个动作。
If I use can :manage, Post it works but I don't want to give all permissions, only some. 如果我can :manage, Post使用can :manage, Post使用can :manage, Post但我不想授予所有权限,仅授予部分权限。
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 ActiveAdmin Sortable gem与资源一起使用时,请执行一项操作

:sort

will be added to the controller for your Post . 将会添加到您的Post的控制器中。 I think you can use 我想你可以用

can(:sort, Post)

in the ability.rb file. 在capability.rb文件中。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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