Forum: Ruby on Rails Where to place a global function

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Steve L. (Guest)
on 2006-01-06 21:42
(Received via mailing list)
Hi all,

I have a little function called format_price(price) that simply formats
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
find it in app/controllers/application.rb. Where do I put it so it's
available to all views?



Steve L.
   * Universal Troubleshooting Process courseware
   * Troubleshooting Techniques of the Successful Technologist
   * Rapid Learning: Secret Weapon of the Successful Technologist
   * Troubleshooters.Com
James A. (Guest)
on 2006-01-06 21:45
(Received via mailing list)

- james
Steve L. (Guest)
on 2006-01-06 22:22
(Received via mailing list)
Thanks James,

Confirmed! It worked perfectly placing it where you suggested.

Lance England (Guest)
on 2006-01-06 22:31
(Received via mailing list)
I did the same thing until I realized it was built in:
This topic is locked and can not be replied to.