# Strange behavior with link\_to for "blog" and "gallery"

**URL:** <https://www.ruby-forum.com/t/strange-behavior-with-link-to-for-blog-and-gallery/98278>\
**Category:** Rails\
**Created:** [July 13, 2006, 5:11pm UTC](https://www.ruby-forum.com/t/strange-behavior-with-link-to-for-blog-and-gallery/98278 "2006-07-13T17:11:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sporkyy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@sporkyy](https://www.ruby-forum.com/u/sporkyy)\
**Post date:** [July 13, 2006, 5:11pm UTC](https://www.ruby-forum.com/t/strange-behavior-with-link-to-for-blog-and-gallery/98278/1 "2006-07-13T17:11:46Z")

</div>

Okay, what’s so different about the bellow code? When I use the link\_to  
function in a partial (three times passing “Stats”, “Blog”, and  
“Gallery”)…

```
<%= link_to(menuItem.to_s, :controller=>menuItem.to_s.downcase)%>

```

I get…  
[Stats](https://www.ruby-forum.com/stats)  
[Blog](https://www.ruby-forum.com/blog)  
[Gallery](https://www.ruby-forum.com/gallery)

and in my .css file I have:

a:link {  
text-decoration: none;  
color: #661;  
}

BUT this only works for the “Stats” link. “Blog” and “Gallery” just  
look like the default html link. If I change the link\_to line to read:  
\<%= link\_to(menuItem.to\_s, :controller=\>menuItem.to\_s.downcase +  
“x”)%\>

everything looks fine but now I have a link to the wrong controller.  
What gives?

---

<div class="post-metadata">

**Author:** ![sporkyy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@sporkyy](https://www.ruby-forum.com/u/sporkyy)\
**Post date:** [July 13, 2006, 5:18pm UTC](https://www.ruby-forum.com/t/strange-behavior-with-link-to-for-blog-and-gallery/98278/2 "2006-07-13T17:18:26Z")

</div>

I guess link\_to is not the problem because if I just put html code  
directly into the layout I still get the problem.

```
 <a href="/stats">Stats</a>
 <a href="/blog">Blog</a>
 <a href="/gallery">Gallery</a>

```

this alone produces the error. I’m confused.

---

<div class="post-metadata">

**Author:** ![sporkyy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@sporkyy](https://www.ruby-forum.com/u/sporkyy)\
**Post date:** [July 13, 2006, 5:27pm UTC](https://www.ruby-forum.com/t/strange-behavior-with-link-to-for-blog-and-gallery/98278/3 "2006-07-13T17:27:12Z")

</div>

All right. It’s becomming embarrasing.

This only happens with links that I have selected at some point. Once I  
select “Stats” and then reload the page the same thing happens.

So I guess I need to put into my .css file something like this…

```
a:visited {
    text-decoration: none;
    color: #230;
}
```

---

<div class="post-metadata">

**Author:** ![sporkyy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@sporkyy](https://www.ruby-forum.com/u/sporkyy)\
**Post date:** [July 13, 2006, 5:26pm UTC](https://www.ruby-forum.com/t/strange-behavior-with-link-to-for-blog-and-gallery/98278/4 "2006-07-13T17:26:56Z")

</div>

All right. It’s becomming embarrasing but I still don’t know how to fix  
it.

This only happens with links that I have selected at some point. Once I  
select “Stats” and then reload the page the same thing happens.

So I guess I need to put into my .css file something like this…

```
a:visited {
    text-decoration: none;
    color: #230;
}
```
