2015-09-15 65 views
3

我创建了一个自定义的formtastic输入,它在参数中带有一个URL。 当在视图中使用输入时,它按预期工作。Activeadmin过滤器:如何使用路径作为过滤器方法参数

但我想在activeadmin过滤器中使用此自定义输入。 这也按预期,除非我要指定网址PARAM:

这项工作:

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路径路径方法?

感谢您的帮助。

回答

2

我成功做到这一点使用url_helpers在一个进程:

filter :my_field, as: :my_custom_input, url: proc { Rails.application.routes.url_helpers.autocomplete_alert_product_name_admin_claims_path }