gpt4 book ai didi

ruby-on-rails - Activeadmin-在索引页面中显示自定义收集操作

转载 作者:行者123 更新时间:2023-12-04 13:16:33 25 4
gpt4 key购买 nike

这可能很简单,但是我似乎无法弄清楚为什么我的收款 Action 没有出现。根据文档,看来我需要做的就是在传递给注册的块中调用collection_actions方法。我想在用户的管理页面中添加一个名为“全部通知”的操作。
这是代码:

ActiveAdmin.register User do

menu :label => "Users", :priority => 3

filter :twitter_id
filter :facebook_id
filter :created_at
filter :allows_notifications
filter :created_at

actions :all, except: [:destroy, :new]

collection_action :notify_all, :method => :post do
puts "notifying...."
end

batch_action :flag do |selection|
puts "flagging...."
end

index do
selectable_column
column "", :sortable => false do |user|
"<img src='#{user.avatar_url}' alt='user avatar' style='width:24px; height:24px;'/>".html_safe
end
column :uuid
column :twitter_id
column :facebook_id
column :allow_notifications do |user| user.allow_notifications ? "true" : "false" end
column :blocked do |user| user.blocked ? "true" : "false" end
column :created_at

default_actions
end

form do |f|
f.inputs :allow_notifications,:blocked
f.buttons
end

show do
attributes_table do
row "Avatar" do |user|
"<img src='#{user.avatar_url}' alt='user avatar'/>".html_safe
end
row :uuid
row :twitter_id
row :facebook_id
row :allow_notifications do |user| user.allow_notifications ? "true" : "false" end
row :blocked do |user| user.blocked ? "true" : "false" end
row :created_at
row "Active Events" do |user| user.active_events.size end
row "Conversations" do |user| user.conversations.size end
row "Comments" do |user| user.comments.size end
end
active_admin_comments
end


end

我在用户页面上的任何地方都看不到notify_all操作:

路线在那里。我是否需要自定义索引 View 以添加收集操作?

最佳答案

是的,您必须在user.rb配置中添加一些内容

action_item :only => :index do
link_to('Notify All', notify_all_admin_users_path)
end

这将在标题栏上的“新用户”链接旁边添加一个链接。

关于ruby-on-rails - Activeadmin-在索引页面中显示自定义收集操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21719827/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com