活动管理员:同一列中的多个操作,类似于查看,编辑,删除 [英] Active Admin: Multiple Actions in same column similar to View, Edit, Delete
本文介绍了活动管理员:同一列中的多个操作,类似于查看,编辑,删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用活动管理宝石为我的ruby on rails应用程序提供管理控制台。我遇到一个问题,我希望对索引页面上的每个项目都执行多个自定义操作,例如查看,编辑,删除。但是,当添加自定义操作时,仅显示最后一个而不是全部。
I am using active admin gem to have a admin console for my ruby on rails application. I am having a problem where i want to have multiple custom actions to every item on index page just like View,Edit, Delete. But when adding custom action only the last one is displayed instead of all.
index do
column 'Instructor Name',:user
column 'Email Address', :email
column 'Phone Number', :phone
column 'website', link_to 'google', 'www.google.com'
column :bio
actions defaults: false do |application|
if application.user.instructor == 2
button_to 'Disapprove', instructor_deny_user_path(application.user.id), method: :put
else
button_to 'Approve', instructor_approve_user_path(application.user.id), method: :put
end
link_to "resume",getresume_instructor_applications_path(id: application.id)
end
end
仅显示恢复链接,而不是批准/拒绝并恢复
Only resume link is shown instead of Approve/Disprove and resume
我在做什么错
推荐答案
如果您的ActiveAdmin> = 1.0.0.preX,则可以执行以下操作:
If you have ActiveAdmin >= 1.0.0.preX, you can do this:
actions defaults: false do |application|
if application.user.instructor == 2
action_item 'Disapprove', instructor_deny_user_path(application.user.id), method: :put
else
action_item 'Approve', instructor_approve_user_path(application.user.id), method: :put
end
action_item "resume", getresume_instructor_applications_path(id: application.id)
end
如果使用0.6.x:
actions defaults: false do |application|
if application.user.instructor == 2
text_node link_to 'Disapprove', instructor_deny_user_path(application.user.id), method: :put
else
text_node link_to 'Approve', instructor_approve_user_path(application.user.id), method: :put
end
link_to "resume", getresume_instructor_applications_path(id: application.id)
end
这篇关于活动管理员:同一列中的多个操作,类似于查看,编辑,删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文