On Miércoles, 14 de Abril de 2010 20:57:25 Soren Christensen escribió:
> Hi,
>
> I have a calculation defined like this:
>      config.columns[:num_payments].calculate = :avg
>
> This works just fine except in this one case.
>
> I have previously used the live search to find some records. The search
> is stored in my session.
> Next time I come back to this controller the same search will be run.
>
> BUT in the mean time the databases has changed so this search now comes
> up empty.
> So the calculation is now being called on an empty list. Which results
> in this error.

Fixed, thanks for your report

>
>
>     xxxController#index (ActionView::TemplateError) "undefined method
>     `num_payments' for nil:NilClass"
>
> On line #6 of
> vendor/plugins/active_scaffold/frontends/default/views/_list_calculations.h
>tml.erb
>
>
> 3: <% active_scaffold_config.list.columns.each do |column| -%>
> 4: <td id="<%= active_scaffold_calculations_id(column) if
> column.calculation? %>">
> 5: <% if column.calculation? -%>
> 6: <%= render_column_calculation(column) %>
> 7: <% else -%>
> 8: &nbsp;|
>
> | 9: <% end -%>
>
> The fix is simply to avoid calling the partial list_calculations when
> @records is empty.
> To do so change
> vendor/plugins/active_scaffold/frontends/default/views/_list.html.erb to
> (notice line 18):
>
> <table cellpadding="0" cellspacing="0">
> <thead>
> <tr>
> <%= render :partial => 'list_column_headings' %>
> </tr>
> </thead>
> <tbody class="messages">
> <tr>
> <td colspan="<%= active_scaffold_config.list.columns.length + 1 -%>"
> class="messages-container">
> <%= render :partial => 'list_messages' %>
> </td>
> </tr>
> </tbody>
> <tbody class="records" id="<%= active_scaffold_tbody_id %>">
> <% if [email protected]? -%>
> <%= render :partial => 'list_record', :collection => @page.items,
>
> :locals => { :hidden => false, :dont_show_calculations => true } %>
>
> <% end -%>
> <% if active_scaffold_config.list.columns.any? {|c| c.calculation?} and
> [email protected]? -%>
> <%= render :partial => 'list_calculations' %>
> <% end -%>
> </tbody>
> </table>
> <%= render :partial => 'list_pagination' %>

-- 
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en.

Reply via email to