In ci_controller i wrote
def search_ci
page = (params[:page] ||= 1).to_i
software_cis_per_page = 3
offset = (page - 1) * software_cis_per_page
@software_cis = SoftwareCi.find_by_sql([“select * from software_cis
where name like ? and status like ? and citype like ? and ci_class like
?”, “%” + params[:ci][:name] + “%”, “%” + params[:ci][:status] + “%”,
“%” + params[:ci][:citype] + “%”, “%” + params[:ci][:ci_class] + “%” ])
@software_ci_pages = Paginator.new(self, @software_cis.length,
software_cis_per_page, page)
@software_cis = @software_cis[offset…(offset + software_cis_per_page -
1)]
end
and in the view search_ci.rhtml,
<%= link_to(‘previous page’, {:params => params.merge(‘page’ =>
@software_ci_pages.current.previous)}) if
@software_ci_pages.current.previous %>
<%= ’ | ’ if @software_ci_pages.current.previous and
@software_ci_pages.current.next %>
<%= link_to(‘next page’, {:params => params.merge(‘page’ =>
@software_ci_pages.current.next)}) if @software_ci_pages.current.next %>
The first page is displayed. But when we click on the ‘next page’ an
error occurs… “can’t convert nil into String”
I printed the value in ‘page’ variable. It is 1 always.
any idea on how to fix this error.