我已经在我的控制器中写了这个:
def index
@invoices = Invoice.paginate(:page => params[:page], :per_page => 3)
@invoices = Invoice.all(:select=>"invoices.id, invoices.invoice_name,
invoices.invoice_number, invoices.invoice_date,
invoices.invoice_sent, invoices.current_eta,
invoices.invoice_status, invoices.invoice_amount,
projects.project_name, clients.client_name,
companies.company_name, currencies.symbol as invoice_symbol",
:joins => "left outer join projects on invoices.project_id = projects.id
left outer join clients on projects.client_id = projects.id
left outer join currencies on currencies.id = projects.currency_id
left outer join companies on clients.company_id = companies.id",
:order =>"invoice_name desc")
if @invoices.blank?
flash[:notice] = "There are no Invoices defined. You can create them by clicking 'New Invoice'"
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @invoices }
end
end
在我的视图文件中,我写了这个:
<div class="digg_pagination">
<div clas="page_info">
<%= page_entries_info @invoices %>
</div>
<%= will_paginate @invoices, :container => false %>
</div>
但我收到此错误:
NoMethodError in Invoices#index
Showing /home/icicle/work/code/invoiced/app/views/invoices/_list.html.erb where line #59 raised:
undefined method `total_pages' for #<Array:0xbdfb708>
Extracted source (around line #59):
56: </table>
57: <div class="digg_pagination">
58: <div clas="page_info">
59: <%= page_entries_info @invoices %>
60: </div>
61: <%= will_paginate @invoices, :container => false %>
62: </div>
我还尝试更改 will_paginate gem 的版本,但仍然遇到相同的错误。有人可以帮我吗?