On Martes, 16 de Marzo de 2010 05:18:27 Nick Rogers escribió:
> Add something like this to the helper for your scaffold's controller.
>
> def precio_column(record)
> sprintf('%.2f', record.precio)
> end
>
> or use number_to_currency(), or number_with_precision() instead of
> sprintf().
>
> There also appears to be a more correct way of doing this using the
> options[:format]
> in the controller and i18n, which is outlined in here somewhere...
> http://wiki.github.com/activescaffold/active_scaffold/api-column
> But I cannot figure out exactly what the option content would be. Can
> someone shed some light?
config.columns[:precio].options[:format] = :currency
or
config.columns[:precio].options[:format] = :number
For spanish (which uses , for decimal separator and . for thousand delimiter)
for example, it enables to enter numbers as:
10.57 => 10.57
10,57 => 10.57
1.000,05 => 1000.05
1.000 => 1000.00
Also, AS will render your numbers with spanish separator and delimiter.
Without setting the format you shouldn't have any problem entering 10.57
>
> On Mon, Mar 15, 2010 at 8:08 PM, Head777 <[email protected]> wrote:
> > Hey, thanks for the help i made it, and works great!!
> >
> > But i want some help more xD with another problem, see i have a field
> > in my table call "price" and when i made the migration i made the
> > field like this:
> > t.decimal :precio, :precision => 8, :scale => 2, :default => 0
> >
> > And make me the table without a problem, but now when in my form i
> > want to make a price like this:
> > http://iv.pl/images/07250267848633729053.jpg
> >
> > and when stored in my table, show me the price in this way!
> > http://iv.pl/images/90597016410276899628.jpg
> >
> > Really i dont know whats the matter, because when i made the excercise
> > in the book "Agile Web Development" it make it in this way, and no
> > give me any problem and in my table i see no problems too.
> >
> > Hope you can help me, again xD
> >
> > --
> > 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]<activescaffold%2Bunsubscribe@
> >googlegroups.com> .
> > For more options, visit this group at
> > http://groups.google.com/group/activescaffold?hl=en.
--
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.