Topic: Rails number_with_delimiter return integer without delimiter

I'm usually using number_with_delimiter to make my integer or my decimal more easy to read, I have once problem with it when using it inside controller but it solved that time. Now I don't know what happen actually when I just simply put those function on my view it return integer without delimiter.

Please see this simulation I create to show the differences.

<td><%= number_to_currency(stock.qty) %></td>
<td><%= (number_with_delimiter number_with_precision stock.qty, :precision => 2) %></td>
<td><%= number_with_delimiter(stock.qty) %></td>
<td><%= stock.qty %></td>

Result:

$100,070.00    100070    100070    100070.0

So the number_with_delimiter and number_with_precision isn't working also. The thing also is it just happen to this project while the others projects on my local all doing fine. And also on my other branch of this project also fine. So I know that there is something I broke into. But I don't know which one it is, since I also didn't realize and didn't know which one I make it broken, I can't trace through my version control cause there is too much update on it. Please any help. Thank you so much.

Re: Rails number_with_delimiter return integer without delimiter

Hi,

You can try like this one with using comma
number_to_currency(@all_registered_hours_for_atpl_columan[register_hours][4], {:unit => '', :separator => ',', :delimiter => '.', :precision => 2

<%= number_to_currency(@all_registered_hours_for_atpl_columan[register_hours][4], {:unit => '', :separator => ',', :delimiter => '.', :precision => 2})%>

Hope it will be help you.

Last edited by bacancytech (2013-05-14 08:02:55)

Re: Rails number_with_delimiter return integer without delimiter

Thanks for your fast reply smile

What's the differences from :separator and :delimiter?

I done try :delimiter at that time and the result with :delimiter => "," is 10,0070 while the value from database is 10007.00000 LOL. how could is that be?

Just for your FYI, I usually use just number_with_delimiter and all just doing fine, even in my different branch it's working like usual, but not in this branch. And I just can't trace it back, because I didn't even know which file could make that number_with_delimiter change it's result.

I done checking my number_helper on my action pack, but nothing different. sad Sorry for bad grammar, not my first language smile

bacancytech wrote:

Hi,

You can try like this one with using comma
number_to_currency(@all_registered_hours_for_atpl_columan[register_hours][4], {:unit => '', :separator => ',', :delimiter => '.', :precision => 2

<%= number_to_currency(@all_registered_hours_for_atpl_columan[register_hours][4], {:unit => '', :separator => ',', :delimiter => '.', :precision => 2})%>

Hope it will be help you.

Re: Rails number_with_delimiter return integer without delimiter

Sir, I done trying your solution, and it worked! Thanks, at least it can be my solution now, but I just curious about this case sir, I meant why just with number_with_delimiter can't get the same result while I used to be use that only. sad

bacancytech wrote:

Hi,

You can try like this one with using comma
number_to_currency(@all_registered_hours_for_atpl_columan[register_hours][4], {:unit => '', :separator => ',', :delimiter => '.', :precision => 2

<%= number_to_currency(@all_registered_hours_for_atpl_columan[register_hours][4], {:unit => '', :separator => ',', :delimiter => '.', :precision => 2})%>

Hope it will be help you.