Home>

Implementation of search function

I want to search for photo titles
When you search, everything will be reflected in veiw.
The database stores photo titles in the text column.

The search form is written with form_tag.
I wrote it with form_for and form_with. Is it wrong to write? I used form_tag because an error occurred.
gem 'rails', '~>5.0.7', '>= 5.0.7.2'

Added search action to tweets controller

Conditions when searching on tweet.rb.
Tweet.where ('text LIKE (?)', "% # {Search}%") is not working well
It feels like Tweet.all is working.

Please let me know

  • Answer # 1

    = text_field_tag: search
    Change to

    = text_field_tag: keyword

Related articles