Note that there are some explanatory texts on larger screens.

plurals
  1. POUndefined method 'total_entries' after upgrading Rails 2.2.2 to 2.3.5
    primarykey
    data
    text
    <p>I am upgrading a Rails application from 2.2.2 to 2.3.5. The only remaining error is when I invoke <code>total_entries</code> for creating a jqgrid.</p> <p>Error:</p> <pre><code>NoMethodError (undefined method `total_entries' for #&lt;Array:0xbbe9ab0&gt;) </code></pre> <p>Code snippet:</p> <pre><code>@route = Route.find( :all, :conditions =&gt; "id in (#{params[:id]})" ) { if params[:page].present? then paginate :page =&gt; params[:page], :per_page =&gt; params[:rows] order_by "#{params[:sidx]} #{params[:sord]}" end } respond_to do |format| format.html # show.html.erb format.xml { render :xml =&gt; @route } format.json { render :json =&gt; @route } format.jgrid { render :json =&gt; @route.to_jqgrid_json( [ :id, :name ], params[:page], params[:rows], @route.total_entries ) } end </code></pre> <p>Any ideas? Thanks!</p> <p><strong>EDIT</strong></p> <p>I am able to get it working by removing the block used after <code>find</code>. I also had to move the <code>order_by</code> used by the squirrel plugin as I was getting an undefined method call for it.</p> <p>I don't like the fact that this is less DRY than the previous code by having to use <code>conditions</code> in more than one location. Is there any better way to do this with Rails 2.3.5, will_paginate, and squirrel?</p> <pre><code> if params[:page].present? then @route = Route.paginate :conditions =&gt; "id in (#{params[:id]})", :page =&gt; params[:page], :per_page =&gt; params[:rows], :order =&gt; "`#{params[:sidx]}` #{params[:sord]}" else @route = Route.find(:all, :conditions =&gt; "id in (#{params[:id]})") end </code></pre> <p><strong>EDIT 2</strong></p> <p>Another possibility for this error may be that I was using Ruby 1.8.7 with Rails 2.2.2 and am now using Ruby 1.9.1 with Rails 2.3.5. Were there any major changes between 1.8.7 and 1.9.1 that would prevent the block after the ActiveRecord find to not run?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload