Jump to content

The ultimate community for Ruby on Rails developers.


Photo

locale number format is not applied


  • Please log in to reply
2 replies to this topic

#1 Giacomo

Giacomo

    Signalman

  • Members
  • 13 posts
  • LocationBologna

Posted 09 October 2013 - 10:26 AM

Hi all,

 

I can't understand why my number format specification in it.yml are ignored. 

 

My yml file contains

it:
  number:
    format:
      delimiter: ","
      precision: 5
      significant: false
      strip_insignificant_zeros: false
      separator: ","

And my code is:

<td><%= @pay_check.contract.week_hours %></td>    	  

I get This value:

<td>54.0</td>

Am I missing something?

Thanks to all

 

P.S. Formats for currency are correctly applied.


--

G.


#2 Giacomo

Giacomo

    Signalman

  • Members
  • 13 posts
  • LocationBologna

Posted 09 October 2013 - 11:49 AM   Best Answer

I think I get a solution for that.

Number format in yml file seems to be "directives" for helpers such as number_with_delimiter and aren't "automatically" applied to numbers.


--

G.


#3 Ohm

Ohm

    Guard

  • Members
  • 179 posts
  • LocationCopenhagen

Posted 09 October 2013 - 06:20 PM

You are correct. The formats given in the yml-files are for helpers such as number_with_delimiter and number_to_curreceny.

 

If you want to use these alot, you might do something like

alias_method :nwd :number_with_delimiter
alias_method :ntc :number_to_currency

and then just use the nwd or ntc-methods.


Blog: http://ohm.sh | Twitter: madsohm





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users