Forum: Ruby on Rails inexplicable undefined method errors

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.
Sean O'Hara (Guest)
on 2006-05-31 01:46
(Received via mailing list)
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)

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 reason,
it gives an error:
undefined method `format_price' for #<#<Class:0x267de2c>:0x267ddc8>

Even when I move this function to the controller for my view I still
get the error. But I can't imagine why. Any ideas? I've tried
reloading the server, etc. but something else must be going on here.

This topic is locked and can not be replied to.