gpt4 book ai didi

ruby-on-rails - ActiveAdmin 嵌套资源链接到操作

转载 作者:行者123 更新时间:2023-12-04 17:54:56 26 4
gpt4 key购买 nike

我在展示页面上有表格费用,还有几个嵌套资源的面板

我如何添加链接来编辑、更新、销毁我的嵌套资源?

  show do |fee|
attributes_table do
row(:code, &:code)
row(:fee_group) { |fee| fee.fee_group['name'] if fee.fee_group }
row(:ssr, &:ssr)
row(:costs) { |fee| fee.costs.map { |cost| cost['currency'] }.join(', ') if fee.costs }
row(:seat_group, &:seat_group)
row(:rules, &:seat_group)
end
panel 'Cost' do
fee.costs.each do |cost|
div class: 'list-item' do
attributes_table_for cost do
row :currency
row :price
row :price
row :tax
row :default

Here i need add links

end
end
end
end

最佳答案

必须解决同样的问题,我使用了 member_action 来解决它。这是我的解决方案:

member_action :remove_member, method: :post do
user = User.find(params[:user_id])
resource.users.delete(user)
redirect_to resource_path, notice: I18n.t('admin.clubs.remove_member_success')
end

在展示部分:

panel do
table_for club.users do
column :rut
column :last_name
column do |user|
link_to(I18n.t('admin.clubs.remove_member'),
remove_member_admin_club_path(resource, user_id: user.id),
method: :post,
data: { confirm: 'Are you sure?' })
end
end
end

关于ruby-on-rails - ActiveAdmin 嵌套资源链接到操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41165916/

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