title: Using Simple Search with Kaminari Pagination Gem
body: <p>I am trying to apply pagination to my rails app using Kaminari.  I am also incorporating a simple search form based on the <a href="http://railscasts.com/episodes/37-simple-search-form" rel="nofollow">Railscast Episode #37</a>.  When I try to apply the kaminari page and per methods I get the error 'undefined method page'. Below is the code I'm using.</p>
  
  <p>posts_controller.rb</p>
  
  <pre><code>def index
    @posts = Post.search(params[:search]).page(params[:page]).per(2)
  end
  </code></pre>
  
  <p>post.rb </p>
  
  <pre><code>def self.search(search)
    if search
      find(:all, conditions: ['title || body LIKE ?', "%#{search}%"], order: "created_at DESC")
    else
      find(:all)
    end
  end
  </code></pre>
  
  <p>index.html.erb</p>
  
  <pre><code>&lt;%= paginate @posts %&gt;
  </code></pre>
  
  <p>When I remove the pagination the search works fine.  When I remove the search the pagination works fine.  I just can't seem to use them both and have the code function properly.  Please advise if there is something in my code that I am missing that is causing this not to work properly.</p>