title: Rails 4 search bar
body: <p>I'm trying to create a search bar in my Rails 4 app. I'm my user db has 'name' and 'email' columns for the user's - I want users to be able to search for other users by name or id.</p>
  
  <p>I'm currently getting this:</p>
  
  <pre><code>ActiveRecord::RecordNotFound in UsersController#index
  Couldn't find all Users with 'id': (all, {:conditions=&gt;["name LIKE ?", "%hi@example.com%"]}) (found 0 results, but was looking for 2)
  </code></pre>
  
  <p>Does anyone know what I'm doing wrong? I've looked at railscasts and a few forums etc but cant get past this point at the moment. </p>
  
  <p>index.html.erb:</p>
  
  <pre><code>&lt;% form_tag users_path, :method =&gt; 'get' do %&gt;
    &lt;p&gt;
      &lt;%= text_field_tag :search, params[:search] %&gt;
      &lt;%= submit_tag "Search", :name =&gt; nil %&gt;
    &lt;/p&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>model/user.rb:</p>
  
  <pre><code>  def self.search(search)
      if search
        find(:all, :conditions =&gt; ['name LIKE ?', "%#{search}%"])
      else
        find(:all)
      end
    end
  </code></pre>
  
  <p>users_controller.rb:</p>
  
  <pre><code>  def index
      @users = User.search(params[:search])
    end
  </code></pre>
  
  <p>routes.rb:</p>
  
  <pre><code>  get     'search'   =&gt;      'users#index'
  </code></pre>