# Problems with link\_to

**URL:** <https://www.ruby-forum.com/t/problems-with-link-to/135140>\
**Category:** Rails\
**Created:** [April 18, 2008, 11:01am UTC](https://www.ruby-forum.com/t/problems-with-link-to/135140 "2008-04-18T11:01:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![claus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@claus](https://www.ruby-forum.com/u/claus)\
**Post date:** [April 18, 2008, 11:01am UTC](https://www.ruby-forum.com/t/problems-with-link-to/135140/1 "2008-04-18T11:01:19Z")

</div>

ddaccordion.init({ headerclass: "expandable", ..... \</script

- \<%= link\_to "institut", {:controller =\> "news"} %\>
i have an accordion navigation and the headers, which should expand on click, should link to my different sites.everything works fine, however, when the link\_to method is nested in a tag where my shared css class, which javascript uses do locate my expandable headers, appears, the link doesn't work any longer. i hope u can help me.

---

<div class="post-metadata">

**Author:** ![claus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@claus](https://www.ruby-forum.com/u/claus)\
**Post date:** [April 18, 2008, 2:15pm UTC](https://www.ruby-forum.com/t/problems-with-link-to/135140/2 "2008-04-18T14:15:10Z")

</div>

not with that information.

what does mean doesn’t work any longer? the link isn’t displayed? it’s  
displayed but does not react to clicks?

> “when the link\_to method is nested in a tag”  
> what tag?

how does the generated html output look like? are there any links?  
maybe it’s just a css problem… who knows?  
try to replace the link\_to with a simple tag, that links to  
“[http://www.rubyonrails.org/](http://www.rubyonrails.org/)” or something othe reliable…

---

<div class="post-metadata">

**Author:** ![claus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@claus](https://www.ruby-forum.com/u/claus)\
**Post date:** [April 18, 2008, 2:30pm UTC](https://www.ruby-forum.com/t/problems-with-link-to/135140/3 "2008-04-18T14:30:52Z")

</div>

Thorsten M. wrote:

> not with that information.
> 
> what does mean doesn’t work any longer? the link isn’t displayed? it’s  
> displayed but does not react to clicks?

yeah. the link is displayed, but doesn’t work. if i change the class to  
any other css class (not used from javascript) everythings just fine.  
BUT i NEED to work with a shared class in this case.

> “when the link\_to method is nested in a tag”  
> what tag?

- \<%= link\_to "institut", {:controller =\> "news"}
 ...doesn't work- \<%= link\_to "institut", {:controller =\> "news"}, :class =\> "sharedClass" %\>
 ...doesn't work- \<%= link\_to "institut", {:controller =\> "news"}
 ...works fine- \<%= link\_to "institut", {:controller =\> "news"}, :class =\> "anyOtherClass" %\>
 ...works fine

> how does the generated html output look like? are there any links?

yeah. the link is there, but doesn’t link to my view

> maybe it’s just a css problem… who knows?

i’m quite shure, cause i’ve tested every permutation with several css  
classes.

> try to replace the link\_to with a simple tag, that links to  
> “[http://www.rubyonrails.org/](http://www.rubyonrails.org/)” or something othe reliable…

that works but doesn’t give me the points, sorry

i hope with this info u r able to help me? thanx so long. claus

---

<div class="post-metadata">

**Author:** ![claus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@claus](https://www.ruby-forum.com/u/claus)\
**Post date:** [April 18, 2008, 2:57pm UTC](https://www.ruby-forum.com/t/problems-with-link-to/135140/4 "2008-04-18T14:57:07Z")

</div>

now we’re missing the one thing: the CSS content for sharedClass

since that’s obviously the source of the trouble

> yeah. the link is there, but doesn’t link to my view  
> means?  
> the link is there, the href is correct but doesn’t work (my guess)  
> the link is there but the href points to nowhere? (can’t imagine that,  
> since ling\_to is very reliable)

---

<div class="post-metadata">

**Author:** ![claus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@claus](https://www.ruby-forum.com/u/claus)\
**Post date:** [April 18, 2008, 4:52pm UTC](https://www.ruby-forum.com/t/problems-with-link-to/135140/5 "2008-04-18T16:52:20Z")

</div>

Thorsten M. wrote:

> now we’re missing the one thing: the CSS content for sharedClass
> 
> since that’s obviously the source of the trouble

here it is:

.expandable  
{  
cursor: pointer;  
font-size: 1.5em;  
padding-left: 1.5em;  
}

> > yeah. the link is there, but doesn’t link to my view  
> > means?  
> > the link is there, the href is correct but doesn’t work (my guess)

–\> no.

> the link is there but the href points to nowhere? (can’t imagine that,  
> since ling\_to is very reliable)

–\> yeah. the link is there, but doesn’t point to my view.

i’m not able to imagine, what could be wrong. damn. thanx again for your  
help.

---

<div class="post-metadata">

**Author:** ![claus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@claus](https://www.ruby-forum.com/u/claus)\
**Post date:** [April 18, 2008, 5:39pm UTC](https://www.ruby-forum.com/t/problems-with-link-to/135140/6 "2008-04-18T17:39:03Z")

</div>

DO THIS BRO :

[Option 1]  
\<%= link\_to “

- institut
”, {:controller =\>  
“news”, :action =\> “xxx”} %\>

[Option 2]

- \<%= link\_to "institut", {:controller =\> "news", :action =\> "xxx"}, "class" =\> "sharedClass" %\>

What do you think?

Enjoy,  
Reinhart  
[http://teapoci.blogspot.com](http://teapoci.blogspot.com)

---

<div class="post-metadata">

**Author:** ![claus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@claus](https://www.ruby-forum.com/u/claus)\
**Post date:** [April 18, 2008, 6:20pm UTC](https://www.ruby-forum.com/t/problems-with-link-to/135140/7 "2008-04-18T18:20:30Z")

</div>

… thus i’ve tried everything u wrote me. nothing worked. i think the  
problem is, what javascript does with this class.

if somebody is interested in my problem:

here s the link of the js source:

[js  
code](http://stud3.tuwien.ac.at/~e0503876/igw_sketch/javascript/ddaccordion.js)

have a look at the init function on the end of the code. maybe u r able  
to find something…?

greets claus

---

<div class="post-metadata">

**Author:** ![claus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@claus](https://www.ruby-forum.com/u/claus)\
**Post date:** [April 18, 2008, 6:21pm UTC](https://www.ruby-forum.com/t/problems-with-link-to/135140/8 "2008-04-18T18:21:22Z")

</div>

heres the working link:

[http://stud3.tuwien.ac.at/~e0503876/igw\_sketch/javascript/ddaccordion.js](http://stud3.tuwien.ac.at/~e0503876/igw_sketch/javascript/ddaccordion.js)

---

<div class="post-metadata">

**Author:** ![claus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@claus](https://www.ruby-forum.com/u/claus)\
**Post date:** [April 18, 2008, 5:24pm UTC](https://www.ruby-forum.com/t/problems-with-link-to/135140/9 "2008-04-18T17:24:54Z")

</div>

try  
\<%= link\_to “institut”, :controller =\> “news” %\>  
\<%= link\_to “institut”, :controller =\> “news”, :action =\> “xxxx” %\>  
(link to an action)  
\<%= link\_to “institut”, :controller =\> “news”, :action =\> “xxxx”, :id  
=\> params[:id] %\> (link to an action, with a specific ID (via the url)

regards  
svend

On Apr 18, 11:01 am, Claus S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
