# Number To Currency help

**URL:** <https://www.ruby-forum.com/t/number-to-currency-help/122200>\
**Category:** Rails\
**Created:** [December 5, 2007, 2:11pm UTC](https://www.ruby-forum.com/t/number-to-currency-help/122200 "2007-12-05T14:11:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [December 5, 2007, 2:11pm UTC](https://www.ruby-forum.com/t/number-to-currency-help/122200/1 "2007-12-05T14:11:01Z")

</div>

Hello fellow railists,

i have recently used the built in number\_to\_currency function for ruby  
on rails to convert my figures in to “Â£”. I have this function in my  
show.rhtml which is:

**Price:** \<%= number\_to\_currency(@sale.price,  
{:unit =\> “£”, :separator =\> “.”, :delimiter =\> “,”}) %\>  
  
\<% end %\>

I want this to be in my list.rhtml so that all the prices can be listed  
as Â£0.00 etc but i have used scaffold to create this and I am only new  
to rails so i need help to use the above code in list.rhtml, here is the  
list.rhtml code can some one please help me and place the code some  
where here to make it work many thanks nish…

h1\>Listing sales

 \<% for column in Sale.content\_columns %\> \<% end %\> 

\<% for sale in @sales %\>

 \<% for column in Sale.content\_columns %\> \<% end %\> \<% end %\>

| \<%= column.human\_name %\> |
| --- |
| \<%=h sale.send(column.name) %\> | \<%= link\_to 'Show', :action =\> 'show', :id =\> sale %\> | \<%= link\_to 'Edit', :action =\> 'edit', :id =\> sale %\> | \<%= link\_to 'Destroy', { :action =\> 'destroy', :id =\> sale }, :confirm =\> 'Are you sure?', :method =\> :post %\> |

\<%= link\_to ‘Previous page’, { :page =\> @sale\_pages.current.previous }  
if @sale\_pages.current.previous %\>  
\<%= link\_to ‘Next page’, { :page =\> @sale\_pages.current.next } if  
@sale\_pages.current.next %\>

  

\<%= link\_to ‘New sale’, :action =\> ‘new’ %\>

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [December 5, 2007, 4:57pm UTC](https://www.ruby-forum.com/t/number-to-currency-help/122200/2 "2007-12-05T16:57:43Z")

</div>

On Dec 5, 2007, at 8:11 AM, Nish P. wrote:

> I want this to be in my list.rhtml so that all the prices can be
> 
> \<%= link\_to 'Show', :action =\> 'show', :id =\> sale %\> \<%= link\_to 'Next page', { :page =\> @sale\_pages.current.next } if @sale\_pages.current.next %\>  
> 
> ## \<%= link\_to ‘New sale’, :action =\> ‘new’ %\>

Assuming that you’re very early in the process (and that you’re using  
Rails 1.2.x), I’d suggest that you redo the generation with  
scaffold\_resource (which is what you’ll get under the name ‘scaffold’  
in Rails 2 anyway).

Usage: script/generate scaffold\_resource ModelName [field:type,  
field:type]

script/generate scaffold\_resource Sale sku:string qty:integer  
‘price:decimal(8,2)’ taxable:boolean

(of course, I’m just guessing at some possible column names and types)

This will start you out with a static set of views with individual  
columns rather than the dynamic ones based on Sale.content\_columns.  
It will be much easier to see how to proceed.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [December 5, 2007, 5:20pm UTC](https://www.ruby-forum.com/t/number-to-currency-help/122200/3 "2007-12-05T17:20:06Z")

</div>

You have taught me something new and its awesome!!! wow i didnt even  
know about this, its amazing, you probably going to change the way i  
approach rails altogether!!
