Activeadmin 过滤器:如何使用路径作为过滤器方法参数
Activeadmin filter : How to use a path as a filter method parameter
我创建了一个带有 URL 参数的自定义 formtastic 输入。
在视图中使用输入时,它按预期工作。
但我想在 activeadmin 过滤器中使用此自定义输入。
这也按预期工作,除非我想指定 URL 参数:
这项工作:
filter :my_field, as: :my_custom_input, url: '/admin/my_models/my_action'
url 参数传递到我的输入,我可以照常使用它。
但我想使用来自路由的标准 rails 路径转换。而且它不起作用:
filter :my_field, as: :my_custom_input, url: my_action_admin_my_models_path
失败是因为找不到“my_action_admin_my_models_path
" 方法。(而且我确定此方法在视图中有效)
我尝试使用 Proc,但它也不起作用,同样的错误。
如何在 activeadmin 过滤器中使用 rails 路由路径方法?
感谢您的帮助。
我在过程中使用 url_helpers 成功地做到了这一点:
filter :my_field, as: :my_custom_input, url: proc { Rails.application.routes.url_helpers.autocomplete_alert_product_name_admin_claims_path }
我创建了一个带有 URL 参数的自定义 formtastic 输入。 在视图中使用输入时,它按预期工作。
但我想在 activeadmin 过滤器中使用此自定义输入。 这也按预期工作,除非我想指定 URL 参数:
这项工作:
filter :my_field, as: :my_custom_input, url: '/admin/my_models/my_action'
url 参数传递到我的输入,我可以照常使用它。 但我想使用来自路由的标准 rails 路径转换。而且它不起作用:
filter :my_field, as: :my_custom_input, url: my_action_admin_my_models_path
失败是因为找不到“my_action_admin_my_models_path " 方法。(而且我确定此方法在视图中有效)
我尝试使用 Proc,但它也不起作用,同样的错误。
如何在 activeadmin 过滤器中使用 rails 路由路径方法?
感谢您的帮助。
我在过程中使用 url_helpers 成功地做到了这一点:
filter :my_field, as: :my_custom_input, url: proc { Rails.application.routes.url_helpers.autocomplete_alert_product_name_admin_claims_path }