当前位置: 动力学知识库 > 问答 > 编程问答 >

ruby on rails - Activeadmin filter : How to use a path as a filter method parameter

问题描述:

I've created a custom formtastic input which take a URL in parameter.

It work as expected when the input is used in a view.

But I want to use this custom input in a activeadmin filter.

This also work as expected, except when I want to specify the URL param :

This work :

filter :my_field, as: :my_custom_input, url: '/admin/my_models/my_action'

The url parameter is passed to my input and i can use it as usual.

But I want to use the standard rails path translation from route. And it doesn't work :

filter :my_field, as: :my_custom_input, url: my_action_admin_my_models_path

This fail because it can't find the "my_action_admin_my_models_path

" method. (And i'm sure this method work in views)

I've tried to use a Proc, but it doesn't work too, same error.

How can I do to use a rails route path method in a activeadmin filter ?

Thanks for your help.

网友答案:

I success to do this using url_helpers in a proc :

filter :my_field, as: :my_custom_input, url: proc { Rails.application.routes.url_helpers.autocomplete_alert_product_name_admin_claims_path }
分享给朋友:
您可能感兴趣的文章:
随机阅读: