Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Use comma separator for decimal in forms

form separator comma

  • Please log in to reply
5 replies to this topic

#1 Giacomo

Giacomo

    Signalman

  • Members
  • 13 posts
  • LocationBologna

Posted 18 November 2013 - 11:39 AM

Hi all,

I need to use comma (,) as decimal separator in forms.

Some suggestions?

 

Thanks


--

G.


#2 Jamie

Jamie

    Controller

  • Moderators
  • 114 posts
  • LocationThe UK

Posted 18 November 2013 - 11:54 AM

Hi

 

Can you explain a little further?

 

What behaviour do you want the comma to do?

 

You could say something in an input with commas in and then on the frontend show them on different lines for example..

gsub(",", "<br />")

Or if you were storing IDs, get another record with them etc.

 

You'll need to explain so we understand what you wish to do :)


Rails developer based in Newcastle, UK.
Web app owner - Twitter lover

#3 Giacomo

Giacomo

    Signalman

  • Members
  • 13 posts
  • LocationBologna

Posted 18 November 2013 - 12:09 PM

Can you explain a little further?

...

You'll need to explain so we understand what you wish to do :)

 

Sure.

I mean, in the "normal" behavior numbers comes with the dot separator for decimals

eg: 5.3

 

It is simple to print out the number with a custom delimiter with number_to_delimiter ...

 

The customer asked me to use the comma as decimal separator in the forms.

In other words, he wants to put numbers with comma as decimal separator in the form fields


--

G.


#4 larabosa

larabosa

    Signalman

  • Members
  • 13 posts

Posted 18 November 2013 - 06:03 PM

Hi,

 

Have you looked at the auto numeric-rails gem?:

https://rubygems.org...rsions/0.1.9.17



#5 james

james

    Guard

  • Moderators
  • 221 posts
  • LocationLeeds, U.K.

Posted 18 November 2013 - 09:07 PM

Have you looked at number_to_human function

http://api.rubyonrai...mberHelper.html


Programming is just about problem solving!


#6 Giacomo

Giacomo

    Signalman

  • Members
  • 13 posts
  • LocationBologna

Posted 20 November 2013 - 11:11 AM

Thanks, I'll take a look at your suggestions


--

G.






Also tagged with one or more of these keywords: form, separator, comma

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users