jhamm
jhamm

Reputation: 25062

Ruby/Rails creating a dynamic method?

I have a fairly large ruby codebase and I am trying to find a method, current_user_has_ownership?. When I grep the codebase it is used in multiple places, but there is no definition found. When I look at the method with pry, the information I get is fairly unhelpful. It shows that the method is in this module:

#<Module:0x007f9f84550200>#methods:

Just a memory location. I assume that rails is creating the method for me, but how do I find what it is? I don't even know what it is called when rails does this for you, so I can't figure out what to google. What is going on and where can I find some documentation on how it works?

Upvotes: 0

Views: 40

Answers (1)

zwippie
zwippie

Reputation: 15525

Try searching for def method_missing and define_method invocations. Chances are that current_user_has_ownership? is defined dynamically or intercepted by a method_missing method.

This will be harder to search for if this code lives in an included gem.

Upvotes: 1

Related Questions