On Jueves, 20 de Octubre de 2011 18:27:38 SOREN CHRISTENSEN escribió:
> Hi,
>
> The helper method name seems to be off - likely something related to how I
> ported the code to the 2.3 environment, or a difference between Rails2 and
> Rails3.
> The override_formatter is in render_column_calculations set to:
> render_amount_#<Proc:0x000000010e969380@/......_controller.rb:39>
>
> Is there some setup of the Proc that happens elsewhere that I have missed ?
> Do you have an example of the Proc doing formatting as well ?
You are right, render_#{column.name}_#{column.calculate} doesn't work with a
proc, you can try with this:
render_#{column.name}_#{column.calculate.is_a?(Proc) ? :calculate :
column.calculate}
>
> /S
>
>
>
> On 10/20/11 12:27 AM, "Sergio Cambra .:: entreCables S.L. ::."
>
> <[email protected]> wrote:
> >On Miércoles, 19 de Octubre de 2011 21:04:45 SOREN CHRISTENSEN escribió:
> >> Excellent.
> >>
> >> Forgot to say that I'm in 2.3 but back ported the proc ability to
> >> AS2.3/2.4.
> >>
> >> How to you override the formatting for the calculation, or is the proc
> >> supposed to return everything ?
> >
> >You should define render_quantity_sold_sum method to formatting the
> >calculation
> >Or you can format it in the proc
> >
> >> /S
> >>
> >> On 10/19/11 5:20 AM, "Sergio Cambra .:: entreCables S.L. ::."
> >>
> >> <[email protected]> wrote:
> >> >On Martes, 18 de Octubre de 2011 00:57:23 SOREN CHRISTENSEN escribió:
> >> >> Hi,
> >> >>
> >> >> Has anyone put in the effort to get the standard ActiveScaffold
> >> >> calculations work on Virtual Coulmns?
> >> >>
> >> >> Quantity_sold is a virtual column defined in the model (as opposed to
> >> >>
> >> >>being
> >> >>
> >> >> a database column). But AS does not support calculations for those.
> >> >>
> >> >> config.columns[:quantity_sold].calculate = :sum
> >> >>
> >> >> Is this doable with reasonable effort ?
> >> >>
> >> >> /S
> >> >
> >> >You must set a proc, for example:
> >> >
> >> >config.columns[:quantity_sold].calculate = proc{|records|
> >> >records.map(&:quantity_sold).sum}
--
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.