I'm using elasticsearch and have run into a weird issue. I have a form for users to submit their search but for some reason, when a user enters their query and then clicks on the submit button, the last parameter is button= See bellow:
http://lvh.me:3000/products?utf8=(checkmark)&q=tree&button=
Here is the form. Not sure if this is an issue with the form, rails, or elastic search.
section.search
= form_tag main_app.products_path, method: :get
= text_field_tag 'q', nil, placeholder: t(:search)
= button_tag type: 'submit'
= icon('fa fa-search')
(edit) HTML:
<form action="/products" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="✓">
<input type="text" name="q" id="q" placeholder="Search"><button name="button" type="submit">
Any help appreciated!
Your <button name="button" type="submit">
doesn't have any value
attribute (i.e. the default output for button_tag
), hence when the form is submitted, button=
is appended like any other named parameter of your form. If you don't want that parameter to be submitted, you should probably add an empty name into button_tag
, i.e.
button_tag type: 'submit', name: ''