Alias_method interferes ApplicationHelper

Hello,
I’m using Ruby 1.8.4 (darwinport), rails-1.0.0 (gem) , Powerbook / Mac
OS X 10.4.5 , Webrick.
How come Rails always raises NoMethodError for my helper (must_fill and
rp or number_to_currency_rp) in application_helper.rb ?
I doubt that alias_method is the culprit, but if i give #
comment then there will be no errors at all … :confused:
what am i doing wrong? is it a bug or stupid me? Thx


This is my helper:

module ApplicationHelper
alias_method :rp, :number_to_currency_rp

# Rp 1.907.000,00 instead of $1,907,000.00
def number_to_currency_rp(dolar)
  number_to_currency(dolar, {:unit => "Rp ", :separator => ",",

:delimiter => “.”})
end

def must_fill(x)
’ + x + ‘
end
end


From ri -f bs alias:
---------------------------------------------------- Module#alias_method
alias_method(new_name, old_name) => self

  Makes _new_name_ a new copy of the method _old_name_. This can be
  used to retain access to methods that are overridden.

     module Mod
       alias_method :orig_exit, :exit
       def exit(code=0)
         puts "Exiting with code #{code}"
         orig_exit(code)
       end
     end
     include Mod
     exit(99)

  _produces:_

     Exiting with code 99


sig “kind regards” :name => " Arie Kusuma A. ", :callme => " Arie ",
:ym => " riyari3 ", :email => " [email protected] ".chop!,
:dotmac => " ariekusumaatmaja ", :blog => "
http://ariekusumaatmaja.wordpress.com ".chop, :pasrubylangage => %q#
Learn & Enjoy English Together: HugeDomains.com #

Besoin d’apprendre beaucoup plus… deutsch, dutch, italie…
wind lang (donc etre solomon)

You should first define a method and then alias it:

module ApplicationHelper
# Rp 1.907.000,00 instead of $1,907,000.00
def number_to_currency_rp(dolar)
number_to_currency(dolar, {:unit => "Rp ", :separator => “,”,
:delimiter => “.”})
end
alias_method :rp, :number_to_currency_rp

end


Kent