# Link\_to\_unless\_current doesnt work with resources?

**URL:** <https://www.ruby-forum.com/t/link-to-unless-current-doesnt-work-with-resources/145384>\
**Category:** Rails\
**Created:** [August 8, 2008, 4:42pm UTC](https://www.ruby-forum.com/t/link-to-unless-current-doesnt-work-with-resources/145384 "2008-08-08T16:42:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 8, 2008, 4:42pm UTC](https://www.ruby-forum.com/t/link-to-unless-current-doesnt-work-with-resources/145384/1 "2008-08-08T16:42:51Z")

</div>

in my routes.rb i have

map.resources :reviews

then when i do

link\_to\_unless\_current(“reviews”, reviews\_path)

i get a link unless im at “/reviews”

my understanding was that link\_to\_unless\_current should not display a  
link for any of the RESTful routes…

i mean  
/reviews/1 or /reviews/edit/1

both should NOT be links? right??

if not, whats the right way to get it to not link as long as im at  
that resource regardless of whatever my action is??

using rails 2.1… if it makes a difference…

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 8, 2008, 7:59pm UTC](https://www.ruby-forum.com/t/link-to-unless-current-doesnt-work-with-resources/145384/2 "2008-08-08T19:59:38Z")

</div>

no. link\_to\_unless\_current means make a link\_to reviews\_path  
["/reviews"] unless that’s the current uri. you might be looking for  
the functionality of:

link\_to\_unless controller\_name == “reviews”, reviews\_path

which will link to reviews path unless it is the current controller.

RSL

On Fri, Aug 8, 2008 at 10:41 AM, removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 8, 2008, 8:01pm UTC](https://www.ruby-forum.com/t/link-to-unless-current-doesnt-work-with-resources/145384/3 "2008-08-08T20:01:24Z")

</div>

oh yeah. and be aware that a failed create request will use the  
reviews\_path uri and could potentially affect your styling/layout with  
that. i usually override current\_page? with a check for request.post?  
and return false if is. hope that helps.

RSL
