Skip to content

Passing rails url helper to input_html attribute in filter #5026

@mitfik

Description

@mitfik

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!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions