THpubs
THpubs

Reputation: 8172

In rails, how to separate the currency and the cents (decimals) to style them separately?

im using the Ruby money gem to display currency in my app. I need to add the currency and the decimal sperately like this :

<p class="pricing-rate"><sup>$</sup> <%= package.price %> <span>.00</span></p>

So it will look like the image I attached. How can I do this?

enter image description here

Upvotes: 0

Views: 148

Answers (1)

makhan
makhan

Reputation: 4009

The easiest way would be to convert it to string and split on .

<% price = package.price.to_s.split('.') %>
<p class="pricing-rate"><sup>$</sup> <%= price[0] %> <span>.<%= price[1] %></span></p>

Upvotes: 1

Related Questions