I’m using will_paginate on my app and it’s working fine. The problem
came when I had to put search field.
After the search, the first page comes according to the parameter
passed, but when I go to the second page, it don’t brings me the
second page, but a new search with no search parameter restriction. I
tried everything, but didn’t work. Could somebody help me?
Thanks,
Pedro
Gemfile:
gem “rails”, “2.3.8”
gem “will_paginate”, “2.3.15”
CONTROLLER:
@cursos = Curso.paginate :per_page => 12, :page =>
params[:page], :conditions => [‘nome like ?’, “%#{params[:search]}
%”], :order =>‘nome, dia_semana’
VIEW:
<% tabnav :embaixada do %>
<% form_tag :url => ‘/embaixada/cursos’, :method => ‘get’ do %>
<%= text_field_tag :search, params[:search], :value => nil %>
<%= submit_tag “Busca”, :name => nil , :disable_with =>
“Aguarde…”%>
<%end%>
<%= link_to "Adicionar novo curso", :controller => "curso" , :action => "new" , :embaixada_id =>@embaixada.id %> <% end %>
PARTIAL:
<% if @cursos and not @cursos.empty? %>
Curso | Dia Semana | Local | Horrio de incio | Horrio de fim | Professor |
---|---|---|---|---|---|
<%= link_to curso.nome, :controller => :curso, :action => "edit" ,:embaixada_id => @embaixada.id, :curso_id => curso.id %> | <%= curso.dia_semana.capitalize %> | ... ... ...