Helper method nav_path not working


#1

Hi there,

is there any explanation for the following strange behaviour that
occured to me:
I created a helper method in application_helper.rb called “nav_path”,
that is supposed to be returning
an array to me. For some strange reason though, I can’t access this
method from the partial I am
calling it from: I simply get nil instead of anything I am really
returning in the method (I tried a String, too).

As soon as I rename the method to something else, “navpath” i.e., it
starts working the way it is supposed to.

I could not find anything on “nav_path” being reserved for Rails or
something, so this seems to be pretty strange behaviour to me. Any
explanations?

Greetings,
Christoph


#2

As soon as I rename the method to something else, “navpath” i.e., it
starts working the way it is supposed to.

Interesting. It’s probably conflicting with Rails’ named route
helpers. RESTful routes can end in _path, and my guess is that Rails
is intercepting that helper call and trying to give you back the path
for a resource called ‘nav’.

Jeff
softiesonrails.com