Named routes and current_page? incompatibility

Hi,

I have some named routes defined e.g. map.public and wish to use
link_to_unless_current() to disable link.
However, as I’ve seen from forum discussions and the API doc, the issue
lies with the fact that the named_route_url() method generated by a
named route does not default to only_path = true like url_for.
Therefore, the current_page? within link_to_unless_current() will not
match.

Apparently there is a recent alternative so that _path on all named
routes is also provided with _url. I tried this (e.g. using
public_path(…)) and got an undefined_method error. Does anyone know
what package this _path on named routes addition is in? Didn’t say on
the trouble ticket (http://dev.rubyonrails.org/ticket/4693).
I’m using InstantRails, so probably need to update some Rails
components.

Also, I have not delved into the new routing chapter in AWDwR yet - may
provide better way of doing things?

Regards,
Karen

Karen Jenkin wrote:

Hi,

I have some named routes defined e.g. map.public and wish to use
link_to_unless_current() to disable link.
However, as I’ve seen from forum discussions and the API doc, the issue
lies with the fact that the named_route_url() method generated by a
named route does not default to only_path = true like url_for.
Therefore, the current_page? within link_to_unless_current() will not
match.

Apparently there is a recent alternative so that _path on all named
routes is also provided with _url. I tried this (e.g. using
public_path(…)) and got an undefined_method error. Does anyone know
what package this _path on named routes addition is in? Didn’t say on
the trouble ticket (http://dev.rubyonrails.org/ticket/4693).
I’m using InstantRails, so probably need to update some Rails
components.

Also, I have not delved into the new routing chapter in AWDwR yet - may
provide better way of doing things?

Regards,
Karen

FYI I have since discovered - thanks to the post at planetrubyonrials -
that until the _path and REST stuff comes in, you can use
hash_for_your_named_route_url instead within the
link_to_current_unless() function (strips out link). So, for the above
map.public named route, can use hash_for_public_url.