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.

File name
= text_field_tag: search, params [: keyword]
I added params [: keyword] to the search results, but all the search results were reflected and had no effect.

I don't think you can read the tweet.rb if statement well.

Please tell me the cause.

File name<tweets.controller.rb>
 def search
    @tweets = Tweet.search (params [: keyword])
file name<tweet.rb>
def self.search (search)
    if search
      Tweet.where ('text LIKE (?)', "% # {Search}%")
file name<search.html.haml>
      = form_tag (tweets_searches_path, method: 'get') do
        = text_field_tag: search
        = submit_tag 'Search', name: nil
    [email protected] tweets.each do | tweet |
      .main-photo {style: "background-image: url (# {tweet.image});"}
Rails.application.routes.draw do
  devise_for: users
  root to: "tweets # index"
  namespace: tweets do
    resources: searches, only:: index
  resources: tweets do
    resources: comments, only: [: create,: destroy]
  resources: users, only:: show
File name
class TweetsController
  • Answer # 1

    Is thetext_field_tag: searchpart of

    search.html.hamlnottext_field_tag: keyword?