views:

343

answers:

2

I'm using the will_paginate plugin and I get the following error only when I'm running on a server rather than locally:

undefined method `total_pages' for []:Array
Extracted source (around line #8):

5:  <% session[:page] = params[:page] %>
6:  <h2>Previous Scenario</h2>
7: <% end %>
8:  <%= will_paginate @scenarios, :next_label => 'Older', :prev_label => 'Newer' %>
9: <div class="box">
10: <% for scenario in @scenarios %>
11:     <% @created = scenario.created_at %>

Any ideas?

A: 

Does your controller have the other half of the equation, e.g.

@scenario = Scenario.paginate(:page => params[:page]||1)

Alternatively I think you might have a plugin on the server side that is converting your Active Record set into a plain array. I'd need a bit more info to look at that.

Ghoti
@scenarios = Scenario.paginate(:page => params[:page], :per_page => 1, :order => 'created_at DESC', :conditions => {:sim_id => session[:sim_id]})
alamodey
What does logger.error @scenarios.inspect give on production and dev? Also try<%= @scenarios.inspect %>in the views. Are they the same?
Ghoti
+1  A: 

Somehow, @scenarios is an ordinary Array for you and it can't be from Scenario.paginate() method because that one always returns a WillPaginate::Collection object.

jonty