Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion will_paginate
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Raony Vieira ferreira  
View profile  
 More options Aug 26 2010, 11:01 am
From: Raony Vieira ferreira <li...@ruby-forum.com>
Date: Thu, 26 Aug 2010 17:01:09 +0200
Local: Thurs, Aug 26 2010 11:01 am
Subject: will_paginate
Hello Guys
I hope someone can help me
I've been trying but without success to do a pagination using the
will_paginate gem.
When I'm listing all records the system paginates but when I'm doing a
filter to show some records, just show the first five. Someone knows
whats happening?

My code

CONTROLLER

  def index

    @contract = Contract.new(params[:contract])
    page = (params[:page] ||= 1).to_i
    @contracts = Contract.search_index({:page => page})
    @legal_entities = LegalEntity.all(:select => "CD_PESSOA_JURIDICA,
NM_PESSOA", :joins => [:person])

    @persons = Person.all

      respond_to do |format|
        format.html # index.html.erb
      end
  end

  def list

    @contract = Contract.new(params[:contract])
    page = (params[:page] ||= 1).to_i
    @contracts = Contract.find_by_params(params[:contract])
    @legal_entities = LegalEntity.all(:select => "CD_PESSOA_JURIDICA,
NM_PESSOA", :joins => [:person])

    @person = Person.all
    render :index

  end

VIEW
<% form_for(@contract, :url => { :action => "list"}, :onKeyPress =>
"submit();" ) do |f| %>
<!-- Início da Tabela de Filtro -->

<table class="Cabecalho" border="0">
  <thead>
    <tr>
      <td colspan="4" class="titulos">Empresa:<br/>
        <%= select(:contract, :CD_PESSOA_JURIDICA,
                               @legal_entities.collect{ |p| [
p.NM_PESSOA, p.CD_PESSOA_JURIDICA]},
                                { :include_blank => true }) %>
      </td>
    </tr>
    <tr>
      <td width="30%" class="titulos">Número do contrato:<br/>
        <%= f.text_field(:CD_CONTRATO, :style=>"width: 90%;",
:maxlength=>"7", :onKeypress => "apenasnum(this);")%>
      </td>
      <td  width="20%"class="titulos">Ano:<br/>
        <%= f.text_field(:NO_ANO, :style=>"width: 90%;", :onKeypress =>
"apenasnum(this);")%>
      </td>
      <td  width="40%"class="titulos">Objeto do contrato:<br/>
        <%= f.text_field(:DS_OBJETO_CONTRATO, :style=>"width: 80%;",
:onKeypress => "apenastex(this);")%>
      </td>
       <td width="9%" align="right" style="padding-right:35px;">
        <%= image_submit_tag("lupa.png", :title => "Pesquisar")%>
      </td>
    </tr>
  </thead>
</table>

<br/>

<div class="tab_botao">
  <%= link_to ( image_tag("incluir.jpg",:style=>"width: 16px;
heigth:16px; border:0", :title =>"Incluir Novo"))+' Incluir Novo',
new_contract_path %>
</div>

<% if @contracts.empty? %>
<div class="div_registro">
    <p>Nemhum contrato foi encontrado</p>
</div>
<% else %>

<table cellpadding="0" cellspacing="1" class="Cabecalho">
    <thead>
      <tr class="Cabecalho_bg">
        <th align="left" style="padding-left: 5px;">Numero Contrato</th>
        <th align="left" style="padding-left: 5px;">Ano</th>
        <th align="left" style="padding-left: 5px;">Empresa</th>
        <th align="left" style="padding-left: 5px;">Objeto</th>
        <th align="left" style="padding-left: 5px;">Termo Aditivo</th>
      </tr>
    </thead>

    <tbody class="zebra">
       <% @contracts.each do |contract| %>
          <tr>
            <td style="padding-left:5px;"><%= link_to
contract.CD_CONTRATO, contract %></td>
            <td style="padding-left:5px;"><%= contract.NO_ANO %></td>
            <td style="padding-left:5px;" ><%=
contract.legal_entity.person.NM_PESSOA %></td>
            <td style="padding-left:5px;"><%=
contract.DS_OBJETO_CONTRATO %></td>
            <td style="padding-left:5px;"><b><%=
"#{contract.additiv_contracts.size} aditivos" %></b></td>
          </tr>
       <% end %>
    </tbody>
      <tr class="Cabecalho_bg">
        <td colspan="6" class="Result">
          Total de <b><%= @contracts.total_entries %></b> &iacute;tens.
        </td>
      </tr>

      <tr>
        <td colspan="6" class="paginacao">
          <%= will_paginate @contracts %>

        </td>
      </tr>
</table>
  <% end %>
 <% end %>

Cheers
--
Posted via http://www.ruby-forum.com/.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.