私はこれをコントローラーに書きました:
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 のバージョンも変更しようとしましたが、それでも同じエラーが発生します。誰かが私を助けることができますか?