Activeadmin: Passing rails url helper to input_html attribute in filter

Created on 22 Jun 2017  路  1Comment  路  Source: activeadmin/activeadmin

Expected behavior

Setting rails url helper in input_html should be parsed and correctly set to the data attribute:

filter :user, collection: -> { User.all }, input_html: {class: "select-remote-data", "data-ajax-url": -> { users_api_url } }

Actual behavior

No matter in which form I will pass the rails url helper it fails to parse it with error undefined method for,
in the case of passing it directly "data-ajax-url": root_url or it is adding whole proc object into data attribute if I will pass as above the lambda.

How to reproduce

Simply add `input_html: { "data-url": root_url } to any filter in the AA model.

The idea is to use select2 with a remote call for fetching big data set, for this one I need proper extra attribue which select2 will parse while initializing select.

Update:
Just to mention that for f.input it works correctly:

 f.input :user, as: :select,
   59               collection: User.where(id: object.user_id), include_blank: false,
   60               input_html: {class: "select-remote-data", "data-ajax-url": users_api_url}

Thanks!

Most helpful comment

after merging related PR such will be possible

filter :title, as: :select, input_html: proc{ {'data-ajax-url': users_api_url} }

>All comments

after merging related PR such will be possible

filter :title, as: :select, input_html: proc{ {'data-ajax-url': users_api_url} }
Was this page helpful?
0 / 5 - 0 ratings