Will_paginate

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%>   <br/>   <div id="full_name">      <%= render :partial => "embaixada/cursos" , :locals => { :cursos => @cursos } %>   </div>   <br>    <span class="edit_link"><%= link_to "Adicionar novo curso", :controller => "curso" , :action => "new" , :embaixada_id =>@embaixada.id %></span>   <% end %>

PARTIAL:

<% if @cursos and not @cursos.empty? %> <table class="curso" id="cursos">   <tr class="header">     <th>Curso</th><th>Dia Semana</th><th>Local</th> <th>Horário de início</th> <th>Horário de fim</th> <th>Professor</th>   </tr>   <% @cursos.each do |curso| %>   <tr class="<%= cycle('odd', 'even') %>">    <td><%= link_to curso.nome, :controller => :curso, :action => "edit" ,:embaixada_id => @embaixada.id, :curso_id => curso.id %></td>    <td><%= curso.dia_semana.capitalize %></td> ... ... ... </table> <% end %> <p> <div style="font-size: small"> <%= will_paginate @cursos %> </div>

Have a look in log/development.log to give you some clues as to what is happening. If you still can't work it out have a look at the Rails Guide on Debugging. In particular see how to use ruby-debug to break into your code and inspect data and follow the flow to see what is going wrong.

Colin

Hi Colin,

I found the problem, :params wasn't present on partial, so I did it:

<%= will_paginate @cursos , :previous_label => h("<"), :next_label => h(">"), :params => { "controller"=>"embaixada","action"=>"cursos", "search"=> params[:search]} %>

Thanks!

Pedro