Hi folks. I’ve run into some behavior in a rails app that I don’t
understand. I don’t think it’s specific to rails, but feel free to
redirect me if I’m off-topic.
I wanted to manually invoke the rails router path recognition in one of
my controller classes. When I tried the naive solution:
I got a NameError:
I google codesearched for anyone else doing this sort of thing and
stumbled across the solution of putting the call into a metaclass
class << self
result_params = self.class.recognize_path(uri.path)
I’m quite puzzled as to why the class lookup works in the context of a
metaclass method, but doesn’t in the context of an instance method (or a
normal class method, for that matter), but am not sure if I’m running
into rails metamagic or my own incomplete understanding of ruby. Any
tips for me?