title: Search box to find user in rails
body: <p>I'm somewhat new to rails. I'm going through making the classic twitter clone right now. I want to have a search bar on my homepage that allows the user to search for a twitter handle, and if the handle exists, it will send the user to the show page for that twitter handle. </p>
  
  <p>I've been following a RailsCast on how to implement a simple search, but instead of doing it on the index like the video, I want to do it on the show action. I've run into some problems though. The form sits on my user index view.
  Here is the error:</p>
  
  <pre><code>ActionController::UrlGenerationError in Users#index
  Showing c:/Sites/Projects/twitterapp/twitter/app/views/users/index.html.erb where line #2 raised:
  
  No route matches {:action=&gt;"show", :controller=&gt;"users"} missing required keys: [:id] 
  </code></pre>
  
  <p>Here is the form:</p>
  
  <pre><code>&lt;%= form_tag(user_path, method: 'get') do %&gt;
        &lt;%= text_field_tag(:search, params[:search]) %&gt;
        &lt;%= submit_tag("Search", name: nil) %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Here is my show action:</p>
  
  <pre><code>def show
          @user = User.search(params[:search])
  end
  </code></pre>
  
  <p>And here is my search method in my user model:</p>
  
  <pre><code>def self.search(search)
          if search
              find(:all, conditions:['name LIKE ?', "%#{search}%"])
          else
              find(:all)
          end
  end
  </code></pre>