My case is slightly more complex than below but I’ll give a simple
describe the problem.
There is a ‘book’ table. A user can search for books by typing keywords
for book title and author name in a form. For example: show all books
that include the word ‘peace’ in the title. The search results needs to
controller will look roughly like this
title = params[:search][:title]
authorname = params[:search][:authorname]
form the sql query
sql = 'select * from books… where title =… and author_id=… "
create paginator and results. I’ll be using a custom pagination here
since it’s a find_by_sql.
I know how to do this, the problem is not here…
@book_pages, @books = …
now, the view includes first page of results, the pagination links with
page number in the url and all… the problem is that when clicking on
them (for example clicking on ‘next page’) will never work since it
doesn’t include the request parameter of the book anymore. There is no
longer params[:search][:title] and params[:search][:authorname]. so
clicking on ‘/book/search_results/page=2’ will fail saying that
params[:search][:title] is NIL…
any idea how can i acheive this?