Questions tagged [number-to-currency]

18 questions
30
votes
2 answers

number_to_currency locale converting

Why does number_to_currency(33.50, :locale => :fr) displaying $33.50? It should display it in different currency based on the locale. I would expect a result of 33,50 €. Thanks a lot!
14
votes
2 answers

Rails: Number to currency, delete trailing zeros

How can I use number_to_currency and make it delete the zeros in the decimal part? So if I have a number 30.50, I want to keep the .50, but if I have 30.00, I want to delete those zeros. I see the precision, but I don't know if I can use it…
Hommer Smith
  • 26,772
  • 56
  • 167
  • 296
10
votes
5 answers

Rails number_to_currency delete trailing zeroes right of decimal

I have a dynamically generated table that multiplies price * qty. Some of the prices are in partial cents. For example if the price of an item is 0.0375 I can display that in my table as number_to_currency(0.0375,:precision => 4) => $0.0375 but on…
ctilley79
  • 2,151
  • 3
  • 31
  • 64
7
votes
0 answers

How to Convert Numbers into Indian Systems in Words/Strings

I am required to produce an accurate and reliable method for converting numbers into words for use in official document in the Indian Numbering System (as used in the countries of the Indian subcontinent). The result is supposed to be used for any…
4
votes
1 answer

Multiple currencies in Rails

I want to be able to support multiple (3 for now) currencies on my website. I am a beginner and have doubts on how to do this . I have searched a bit and I have a list of questions. Following are my requirements. I do not want to change the…
3
votes
2 answers

Rails number_to_currency precision doesn't work - is it a bug?

I'm trying to use number_to_currency to get two digits after the decimal dot in Rails 3, but I can get only one. My DB field is defined like this: t.decimal "amount", :precision => 5, :scale => 2 In my template I…
iRonin
  • 470
  • 4
  • 12
2
votes
2 answers

Convert pennies to currency with rails

I am using Stripe and getting currency that is in pennies. So 12.90 looks like 1290. I want to convert this to U.S. Currency but if I try and use the number_to_currency method it ends up looking like 1,290.00. Is there a method to convert the full…
SupremeA
  • 1,519
  • 3
  • 26
  • 43
2
votes
2 answers

number_to_currency rails fails with comparison of String with 0 failed

i'm using rails 3.2 and ruby 1.9.3 i'm using this to display a price: number_to_currency(12.0) in locale :en, it works but in :es I get: comparison of String with 0 failed didn't find it anywhere, anyone? edit: I have updated the number just to be…
devmonster
  • 323
  • 2
  • 12
1
vote
1 answer

Rails number to currency/ foreign currencies query

Hi i am messing around with rails, there is a method built into rails that can convert a decimal number into a currency. I could just change it in the view but i would like to internalize it into the application so that i can save on the…
legendary_rob
  • 12,792
  • 11
  • 56
  • 102
1
vote
1 answer

number to words (Indian numbering system) using javascript

REFERENCE : https://jsfiddle.net/lesson8/5tt7d3e6/ I want to use ASP textbox control to implement number to words functionality! I have javascript function which converts numbers into words onkeyup function. My javascript function: function…
ace
  • 225
  • 4
  • 18
0
votes
1 answer

Can't get decimals to display in text field for Rails 3

I have a brief question... pretty new to rails, and I was wondering if you could help me with an issue that I'm having in code. I have a set of input boxes (it's an online app that asks for revenues and expenses) where I would like to format the…
0
votes
1 answer

How to call image_tag and number_to_currency in dynamcially created html from ERB

I am trying to create an html file from ERB, as I want to save a copy of invoice of a very complicated calculation. My ERB template is using many different calculation and using heavily number_to_currency and image_tag Following is my action…
Kamal Panhwar
  • 2,345
  • 3
  • 21
  • 37
0
votes
2 answers

how to stop "number_to_currency" method from interpreting commas as decimal places for price?

In my Ruby on Rails app, I've got a model called Post which has a column named "Price" in it's database table; this column is decimal type with a precision of 8 and scale of 2. The form for a new Post has a 'text_field' for :price, and in the Post…
hworth
  • 303
  • 3
  • 17
0
votes
1 answer

BigDecimal to Currency with -0.0

I am working on reports for a website and I am currently thinking of what would be the best way to handle BigDecimal -0.0's. The database I'm working with has a lot of them. When these -0.0's are put through number_to_currency(), I get "$-0.00". My…
Isaac
  • 2,246
  • 5
  • 21
  • 34
0
votes
1 answer

Rails - Edit View - Can't save to MySQL:decimal using number_to_currency helper

I have 2 database columns (using mysql) one a decimal(10,2) the other a string. Migration looks like. t.decimal :PRICE, precision: 10, scale: 2 t.string :TOTALTAX In a _form.html.erb partial, I have the following using the number_to_currency…
1
2