Number To Currency help

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’ %>

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
[email protected]

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!!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs