# Link\_to dynamic id problem

**URL:** <https://www.ruby-forum.com/t/link-to-dynamic-id-problem/132991>\
**Category:** Rails\
**Created:** [March 26, 2008, 3:33pm UTC](https://www.ruby-forum.com/t/link-to-dynamic-id-problem/132991 "2008-03-26T15:33:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![newrubygirl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e274bd/32.png) [@newrubygirl](https://www.ruby-forum.com/u/newrubygirl)\
**Post date:** [March 26, 2008, 3:33pm UTC](https://www.ruby-forum.com/t/link-to-dynamic-id-problem/132991/1 "2008-03-26T15:33:43Z")

</div>

Hi.

This works:  
\<%= link\_to “show”, {:action =\> “show”, :id =\> 1 }, {:title =\>  
@table.name } %\>

This does not:  
\<%= link\_to “show”, {:action =\> “show”, :id =\> @table.id }, {:title =\>  
@table.name } %\>

This is all wrapped in a list of names and I’d like to enable the user  
to click on the name and go to the “show” page of the model.

Any ideas on how to make the id dynamic?

Thanks!

---

<div class="post-metadata">

**Author:** ![newrubygirl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e274bd/32.png) [@newrubygirl](https://www.ruby-forum.com/u/newrubygirl)\
**Post date:** [March 26, 2008, 3:37pm UTC](https://www.ruby-forum.com/t/link-to-dynamic-id-problem/132991/2 "2008-03-26T15:37:31Z")

</div>

This works when I changed the table reference. There were 2 loops and  
as soon as I grabbed the inner loop all was good.

> \<%= link\_to “show”, {:action =\> “show”, :id =\> @table.id }, {:title =\>  
> @table.name } %\>
