title: rails 4 will_paginate custom records second page not showing
body: <p>I have created a custom search of books according to the criteria the user enters and I use will_paginate to show them. However, even though the first page shows ok, when I choose the second the following error message appears:</p>
  
  <pre><code>Couldn't find Book with id=show_search_by_title` in show method
  def show
    @book = Book.find(params[:id])
    authorize! :read, @book
  end 
  </code></pre>
  
  <p>In the books_controller there is the following method:</p>
  
  <pre><code>def show_search_by_title
    q = params[:book][:title]
    books = Book.where('title LIKE ?', "%#{q}%")
    @books = books.paginate(page: params[:page], per_page: 10)
  end
  </code></pre>
  
  <p>and the corresponding .erb file is the following:</p>
  
  <pre><code>&lt;% if @books.empty? %&gt;
    There are no books in the Library that fulfill the given criteria
  &lt;% else %&gt;
    &lt;%= will_paginate @books %&gt;
  </code></pre>
  
  <p>The books that complete the given criteria are the following:</p>
  
  <pre><code>&lt;table&gt;    
  &lt;tr&gt;
    &lt;th&gt; Book Title &lt;/th&gt; &lt;th&gt; Author &lt;/th&gt; &lt;th&gt; Category &lt;/th&gt; &lt;th&gt; copies &lt;/th&gt; &lt;th&gt; Rank &lt;/th&gt;
  &lt;/tr&gt;
  
  &lt;% @books.each do |book| %&gt;
  
  &lt;tr&gt;
    &lt;td&gt;&lt;%=book.title %&gt; &lt;/td&gt;
    &lt;td&gt;&lt;%=book.author.name %&gt; &lt;/td&gt;
    &lt;td&gt;&lt;%=book.cat.description %&gt;&lt;/td&gt;
    &lt;td&gt;&lt;%=book.copies %&gt;  &lt;/td&gt;
    &lt;td&gt;&lt;%=book.rank %&gt; &lt;/td&gt;
  &lt;/tr&gt;
  &lt;% end %&gt;
  &lt;/table&gt;
  
  &lt;%= will_paginate @books %&gt;
  
  &lt;% end %&gt;
  </code></pre>
  
  <p>Thank you very much in advance.</p>
  
  <p>my routes for books are:</p>
  
  <pre><code>view_books_books_path            GET    /books/view_books(.:format) books#view_books
  rank_book_books_path             GET    /books/rank_book(.:format) books#rank_book
  update_book_rank_books_path      PATCH  /books/update_book_rank(.:format) books#update_book_rank
  search_by_title_books_path       GET    /books/search_by_title(.:format) books#search_by_title
  search_by_author_books_path      GET    /books/search_by_author(.:format) books#search_by_author
  show_search_by_title_books_path  GET    /books/show_search_by_title(.:format) books#show_search_by_title
  show_search_by_author_books_path POST   /books/show_search_by_author(.:format) books#show_search_by_author
  books_path                       GET    /books(.:format)    books#index
                                   POST   /books(.:format)    books#create
  new_book_path                    GET    /books/new(.:format)    books#new
  edit_book_path                   GET    /books/:id/edit(.:format) books#edit
  book_path                        GET    /books/:id(.:format)    books#show 
  </code></pre>
  
  <p>shows the error in show method:</p>
  
  <pre><code>def show
    @book = Book.find(params[:id])
    authorize! :read, @book
  end 
  </code></pre>