Forum: Ruby on Rails MySql Memory Error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sean McGilvray (Guest)
on 2009-04-11 01:11
(Received via mailing list)
I am getting the following error when I try the following code.

controller.rb

  def index
    @stats = SubscriptionPayment.stats if params[:page].blank?
    @subscriptions = Subscription.paginate(:include => :account, :page
=> params[:page], :per_page => 30, :order => 'accounts.name')
  end

index.html.erb

<% @page_title = 'Subscriptions' %>
<% if @stats %>
  <h1>Revenue Summary</h1>
  <table id="stats">
    <tr>
      <th>Last Month</th>
      <td><%= number_to_currency(@stats[:last_month]) %></td>
    </tr>
    <tr>
      <th>Last 30 Days</th>
      <td><%= number_to_currency(@stats[:last_30]) %></td>
    </tr>
    <tr>
      <th>This Month</th>
      <td><%= number_to_currency(@stats[:this_month]) %></td>
    </tr>
  </table>
<% end %>

<h1><%= @page_title %></h1>
<table id="subscriptions">
  <tr>
    <th>Account</th>
    <th>Amount</th>
    <th>Created</th>
    <th>Next Renewal</th>
    <th>Status</th>
  </tr>
  <% @subscriptions.each do |subscription| %>
    <tr class="<%= 'expired' unless subscription.current? %>">
      <td><%= link_to(h(subscription.account.name), [:admin,
subscription]) %></td>
      <td><%= number_to_currency(subscription.amount) %> <%= "(#
{subscription.discount.name})" if subscription.discount %></td>
      <td><%= subscription.created_at.strftime("%d %B %Y") %></td>
      <td><%= subscription.next_renewal_at.strftime("%d %B %Y") %></
td>
      <td><%= subscription.state %></td>
    </tr>
  <% end %>
</table>

<%= will_paginate(@subscriptions) %>


ERROR

ActiveRecord::StatementInvalid (Mysql::Error: Out of memory (Needed
2096048 bytes):

How do I get around this or fix the current statements?

Thank you,

Sean
This topic is locked and can not be replied to.