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.
C9af522fc39d5de90f21119543c2b9ab?d=identicon&s=25 Steve Litt (Guest)
on 2006-01-06 20: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 Litt
   * Universal Troubleshooting Process courseware
   * Troubleshooting Techniques of the Successful Technologist
   * Rapid Learning: Secret Weapon of the Successful Technologist
   * Troubleshooters.Com
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 James Adam (Guest)
on 2006-01-06 20:45
(Received via mailing list)

- james
C9af522fc39d5de90f21119543c2b9ab?d=identicon&s=25 Steve Litt (Guest)
on 2006-01-06 21:22
(Received via mailing list)
Thanks James,

Confirmed! It worked perfectly placing it where you suggested.

55a3d4a1ddc93ed9f519642f669da5f2?d=identicon&s=25 Lance England (Guest)
on 2006-01-06 21: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.