我创建了一个自定义的formtastic输入,它在参数中包含一个URL。 在视图中使用输入时,它可以正常工作。
但我想在activeadmin过滤器中使用此自定义输入。 这也可以按预期工作,除非我想指定URL参数:
这项工作:
filter :my_field, as: :my_custom_input, url: '/admin/my_models/my_action'
url参数传递给我的输入,我可以像往常一样使用它。 但我想使用路线的标准铁路路径转换。它不起作用:
filter :my_field, as: :my_custom_input, url: my_action_admin_my_models_path
这会失败,因为找不到“my_action_admin_my_models_path” “方法。(我确定这种方法适用于视图)
我试过使用Proc,但它也不起作用,同样的错误。
如何在activeadmin过滤器中使用rails路径路径方法?
感谢您的帮助。
答案 0 :(得分:2)
我在proc:
中使用url_helpers成功完成了这项工作filter :my_field, as: :my_custom_input, url: proc { Rails.application.routes.url_helpers.autocomplete_alert_product_name_admin_claims_path }