I upload to production my page. In localhost, the page, run OK but in Production produce this error in dashboard index.
Passenger error
Processing DashboardController#index (for 190.19.21.199 at 2011-03-04 06:00:27) [GET]
Parameters: {"action"=>"index", "controller"=>"dashboard"}
NoMethodError (undefined method `to_i' for {:page=>nil}:Hash):
searchlogic (2.4.19) lib/searchlogic/active_record/association_proxy.rb:14:in `send'
app/controllers/dashboard_controller.rb:6:in `index'
passenger (3.0.0) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
passenger (3.0.0) lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
passenger (3.0.0) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
passenger (3.0.0) lib/phusion_passenger/classic_rails/application_spawner.rb:321:in `start_request_handler'
passenger (3.0.0) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `send'
passenger (3.0.0) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `handle_spawn_application'
passenger (3.0.0) lib/phusion_passenger/utils.rb:479:in `safe_fork'
passenger (3.0.0) lib/phusion_passenger/classic_rails/application_spawner.rb:270:in `handle_spawn_application'
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:180:in `start'
passenger (3.0.0) lib/phusion_passenger/classic_rails/application_spawner.rb:149:in `start'
passenger (3.0.0) lib/phusion_passenger/spawn_manager.rb:219:in `spawn_rails_application'
passenger (3.0.0) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
passenger (3.0.0) lib/phusion_passenger/spawn_manager.rb:214:in `spawn_rails_application'
passenger (3.0.0) lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
passenger (3.0.0) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
passenger (3.0.0) lib/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_application'
passenger (3.0.0) lib/phusion_passenger/spawn_manager.rb:132:in `spawn_application'
passenger (3.0.0) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.0) helper-scripts/passenger-spawn-server:99
DAshboard Index view
<% content_for :header do -%>
<% unless current_user.nil? %>
Mi Cuenta
<% else %>
Ingrese al sistema
<% end %>
<% end -%>
<% unless current_user.nil? %>
<% unless @movements.blank? %>
<h2>Balance</h2>
<%= get_total_balance(current_user) %>
<h2>Ultimos movimientos</h2>
<table>
<th>Fecha</th>
<th>Debite</th>
<th>Acredite</th>
<th>Total</th&开发者_开发技巧gt;
<% @movements.each do |m| %>
<tr>
<td><%= m.date.to_date %></td>
<td><%= m.debit %></td>
<td><%= m.credit %></td>
<td><%= m.balance %></td>
</tr>
<% end %>
</table>
<%= will_paginate @movements %>
<% else %>
No hay movimientos para mostrar
<% end %>
<% else %>
<div style="width: 40%; margin: 0 auto;">
<%= render :partial => 'sessions/new' %>
</div>
<% end %>
index controller
def index
@movements = current_user.person.saving.movements.paginate :page => params[:page] || 1 unless current_user.nil? || current_user.person.saving.movements.blank?
end
However I use pagination with will paginate through the page. This pagination run OK but no in dashboard index. I see the page once. however i tried to enter again. Produce this error.
Thanks in advice
Use this in your action:
@movements = current_user.person.saving.movements.paginate :page => params[:page] if current_user.present?
@movements = [] if current_user.blank?
You can probably get rid of @movements = [] if current_user.blank?
since you are checking for the existence of current_user in your view anyway.
And this in your view:
<% if @movements.length > 0 %>
<h2>Balance</h2>
<%= get_total_balance(current_user) %>
<h2>Ultimos movimientos</h2>
<table>
<th>Fecha</th>
<th>Debite</th>
<th>Acredite</th>
<th>Total</th>
<% @movements.each do |m| %>
<tr>
<td><%= m.date.to_date %></td>
<td><%= m.debit %></td>
<td><%= m.credit %></td>
<td><%= m.balance %></td>
</tr>
<% end %>
</table>
<%= will_paginate @movements %>
<% else %>
No hay movimientos para mostrar
<% end %>
How does that work?
精彩评论