Hiago Serpa
Hiago Serpa

Reputation: 41

Rails 5 simple search form just won't work

The problem is: the search keeps getting processed by the current controller of the current view. If I'm the the index page (in the PagesController), the query takes place there, just reloading the url like this:

http://localhost:3000/?utf8=%E2%9C%93&query=test+title

I've tried everything and can't find where my logic is wrong.

These are the routes:

get '/search_query', to: 'posts#search_query', as: 'search_query'

Upvotes: 0

Views: 31

Answers (1)

Paul Byrne
Paul Byrne

Reputation: 1615

form_tag generates a form element, so you are nesting a form inside a form here. Try deleting the outer form.

Upvotes: 1

Related Questions