On Dec 5, 2007, at 8:11 AM, Nish Patel wrote:> 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:
>
> <strong>Price: </strong> <%= number_to_currency(@sale.price,
> {:unit => "£", :separator => ".",
:delimiter => ","}) %><br />
> <% 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</h1>
>
> <table>
> <tr>
> <% for column in Sale.content_columns %>
> <th><%= column.human_name %></th>
> <% end %>
> </tr>
>
> <% for sale in @sales %>
> <tr>
> <% for column in Sale.content_columns %>
> <td><%=h sale.send(column.name) %></td>
> <% end %>
> <td><%= link_to ''Show'', :action =>
''show'', :id => sale %></td>
> <td><%= link_to ''Edit'', :action =>
''edit'', :id => sale %></td>
> <td><%= link_to ''Destroy'', { :action =>
''destroy'', :id => sale },
> :confirm => ''Are you sure?'', :method => :post
%></td>
> </tr>
> <% end %>
>
> </table>
>
> <%= 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 %>
>
> <br />
>
> <%= 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 Biedenharn http://agileconsultingllc.com
Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---