title: Search not working. Getting all results instead of specific results Ruby on Rails
body: <p>When I run my search posts in my Rails application, I get all of the posts existing in the database displayed instead of matched results. </p>
  
  <p>Here is my controller method for search:</p>
  
  <pre><code>def search
      @posts=Post.find(:all, :conditions=&gt;['text LIKE ?', "%#{params[:search]}%"])
    end
  </code></pre>
  
  <p>The search.html.erb is:</p>
  
  <pre><code>&lt;table class="table table-striped" summary="All posts"&gt;
      &lt;% @posts.each do |post| %&gt;
      &lt;tr&gt;&lt;td&gt;&amp;nbsp&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Post #&lt;%=post.id%&gt;   &lt;/td&gt;
          &lt;td&gt;&lt;%=post.text%&gt;&lt;/td&gt;
          &lt;%if post.image_file_name%&gt;
          &lt;td&gt;
          &lt;%=image_tag post.image.url %&gt;
          &lt;/td&gt;
          &lt;%end%&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
          &lt;td&gt;&lt;%= link_to("Like", {:action=&gt;'#', :id=&gt;post.id}, :class =&gt; 'action upvote')%&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;%end%&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>Moreover, I have tried putting these in my model:</p>
  
  <pre><code>scope :search, lambda {|query|
          where (["text LIKE ?",  "%#{query}%"])
      }
  def self.search(search)
          if search
              find(:all, :conditions=&gt;['text' 'LIKE ?', "%#{params[:search]}%"])
          else
              find(:all)
          end
      end
  </code></pre>
  
  <p>but I get same results. Anyone can fix this? Thanks.</p>
  
  <h2>UPDATE 1.0:</h2>
  
  <p>Here is the form for search which is located in <code>index.html.erb</code>: </p>
  
  <pre><code>&lt;%=form_for(:post, :method=&gt;'get', :url=&gt;{:action=&gt;'search', :html=&gt; {:multipart=&gt;true}}) do |f| %&gt;
      &lt;p&gt;
          &lt;%=f.text_field(:text)%&gt;
          &lt;%=submit_tag("Search")%&gt;
      &lt;/p&gt;
    &lt;%end%&gt;
  </code></pre>
  
  <hr>
  
  <h2>UPDATE 1.1</h2>
  
  <p>Here is the Gemfile:</p>
  
  <pre><code>source 'https://rubygems.org'
  gem 'rails', '4.0.0'
  gem 'mysql2','~&gt; 0.3.11'
  gem 'paperclip', '~&gt;3.0'
  gem 'sass-rails', '~&gt;4.0.0'
  gem 'bootstrap-sass', '~&gt;3.2.0.2'
  gem 'autoprefixer-rails'
  gem 'acts_as_votable', '~&gt;0.10.0' 
  gem 'uglifier', '&gt;= 1.3.0'
  gem 'coffee-rails', '~&gt; 4.0.0'
  gem 'therubyracer', platforms: :ruby
  gem 'jquery-rails'
  gem 'turbolinks'
  gem 'jbuilder', '~&gt; 1.2'
  group :doc do
    gem 'sdoc', require: false
  end
  </code></pre>