Inexplicable undefined method errors


#1

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:

<%= format_price(hard_product.price_ca) %>

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