Forum: Ruby on Rails inexplicable undefined method errors

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community 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)
   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 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.

Thanks,
Sean
This topic is locked and can not be replied to.