Forum: Ruby on Rails Helper method nav_path not working

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Christoph O. (Guest)
on 2007-03-23 13:15
(Received via mailing list)
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
Jeff C. (Guest)
on 2007-03-23 16:59
(Received via mailing list)
> 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
This topic is locked and can not be replied to.