Displaying 4 results from an estimated 4 matches for "format_price".
2006 Jan 06
3
Where to place a global function
Hi all,
I have a little function called format_price(price) that simply formats the
argument as a dollar sign, dollar amount, dot and penny amount. Then, in
a .rhtml file, I could do this:
<%= format_price(item.unit_price * item.quantity) %>
But where do I put the format_price() function definition? The app couldn''t
find it in app...
2006 May 30
0
inexplicable undefined method errors
Hi All,
I had a function from the pragprog book in my application_helper.rb
file. Here it is:
def format_price(amount)
dollars, cents = amount.divmod(100)
sprintf("$%d.%02d", dollars, cents)
end
I call this function in my view quite simply like this:
<td><%= format_price(hard_product.price_ca) %></td>
This was working fine until today, suddenly for now apparent rea...
2006 Jul 13
1
From the Agile book, page 144 regarding a div tag helper
...n the Rails Agile book here''s what was happening:
>>>
module StoreHelper
def hidden_div_if(condition, attributes = {})
if condition
attributes["style" ] = "display: none"
end
attrs = tag_options(attributes.stringify_keys)
"<div #{attrs}>"
end
# format_price method ...
end
Note that we cheated slightly here. We copied code from the Rails
standard
helper called content_tag( ); that?s how we knew to call tag_options( )
the way
we did.And how did we find the source code of the content_tag( ) method?
We brought up the
RDoc documentation in a browser an...
2006 Jul 03
0
Page 129 of Agile Web Dev on Rails (or pg141 of pdf!)
...:
<% if cart_item == @current_item %>
<tr id="current_item">
<% else %>
<tr>
<% end %>
<td><%= cart_item.quantity %>×</td>
<td><%= h(cart_item.title) %></td>
<td class="item-price"><%= format_price(cart_item.price) %></td>
</tr>
What is it that I can''t see!?
--
Posted via http://www.ruby-forum.com/.