0

In a rails application, the first line of a controller class is:

before_filter :authenticate_user!

I need to put a breakpoint inside the method autheticate_user!.

I discovered that this is a method that is added to the class. So it's not inherited from the super class, If it were i could do:

def authenticate_user!

    super.authenticate_user!

end

Since there's no authenticate_user! in the superclass, this gives me:

NoMethodError (undefined method `authenticate_user!' for #<User:0xbec65c0>)

My problem is that i don't know where to stop the execution during authentication, or how to implement a trick in order to intercept such process.

4

1 回答 1

2

alias_method应该管用:

alias_method :orig_authenticate_user!, :authenticate_user!
def authenticate_user!
  orig_authenticate_user!
end
于 2013-07-21T14:32:52.893 回答