在 ActiveAdmin 上,我有一个这样的表格:请注意,“My thingy”不在数据库中,而是通过 API 中的数据计算得出。
我想为此字段添加过滤器。我想要的是将此abc
文本作为参数发送到我所在的同一编辑操作。
我的表格是这样的:
form do |f|
f.inputs "Details" do
f.input :my_thingy,
label: 'My thingy',
as: :select,
collection: my_thingys,
f.input :my_thingy_filter, label: "Filter My thingy by..."
f.button :filter
end
f.actions
end
我想要的是让这个按钮重定向到同一页面,并将 的值my_thingy_filter
作为参数。
我怎样才能做到这一点?
我使用以下方法解决了这个问题member_action
:
member_action :thingy_filter, method: :patch do
redirect_to edit_thingy_path(resource, thingy_filter: params["thingy"]["thingy_filter"])
end
并formaction
使用按钮:
form do |f|
f.inputs "Details" do
f.input :my_thingy,
label: 'My thingy',
as: :select,
collection: my_thingys,
f.input :my_thingy_filter, label: "Filter My thingy by..."
f.button "Filter", formaction: "thingy_filter"
end
f.actions
end
无论如何,通过添加更好的选择可以更好地解决这个问题
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句