Reputation: 41
My code
<td><%= number_to_currency(x['quote']['USD']['price'], :unit => '$', :separator =>'.', :delimiter => ',', precision: 4) %><br/></td>
When I use it just like that, it is ok, extract the info and put it ok. But when I try to multiply with another variable, it send me an error "ActiveSupport::SafeBuffer can't be coerced into BigDecimal", so I was thinking in turn it into a @, but I am not sure how to do it
Upvotes: 0
Views: 138
Reputation: 3290
You could think number_to_currency
returns a special string
(e.g. "$ 123.0000"), it can't be multiplied with number
directly.
You could multiply first, then use number_to_currency
to format result:
<% result = x['quote']['USD']['price'] * crypto.cost_per %>
<td><%= number_to_currency(result, unit: '$', separator: '.', delimiter: ',', precision: 4) %></td>
Upvotes: 2