# Link\_to

**URL:** <https://www.ruby-forum.com/t/link-to/103762>\
**Category:** Rails\
**Created:** [May 10, 2007, 1:15am UTC](https://www.ruby-forum.com/t/link-to/103762 "2007-05-10T01:15:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![noooooo10](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/35a633/32.png) [@noooooo10](https://www.ruby-forum.com/u/noooooo10)\
**Post date:** [May 10, 2007, 1:15am UTC](https://www.ruby-forum.com/t/link-to/103762/1 "2007-05-10T01:15:08Z")

</div>

Hiya!

I am really new to RoR, and I have a little tiny question:

I have a database column called url. I have a simple bookmarking app  
and I would like a button called “open” that will take the user to the  
url stored in the database. Sounds simple, and the code I used was  
this:

\<%= link\_to ‘Open’, bookmark[“url”] %\>

But I keep getting errors. Anybody know what I would have to do to get  
it to work?

Help is greatly appreciated!

---

<div class="post-metadata">

**Author:** ![noooooo10](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/35a633/32.png) [@noooooo10](https://www.ruby-forum.com/u/noooooo10)\
**Post date:** [May 10, 2007, 5:12am UTC](https://www.ruby-forum.com/t/link-to/103762/2 "2007-05-10T05:12:20Z")

</div>

Hi,

First, you need a model for your table. Then, before the rhtml page  
loads  
you need to find the proper row in that table (you do that in your  
controller) and save it in a variable like @bookmark. Then your code  
will  
look something like

\<%= link\_to ‘Open’, @bookmark.url %\>

I strongly suggest you get a copy of “Agile Web D. with Rails  
2nd  
Ed” and read through the entire tutorial chapters before you go much  
further. There are also numerous free tutorials you find by googling.

Good luck!

Terry

On 5/9/07, noooooo10. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \<%= link\_to ‘Open’, bookmark[“url”] %\>
> 
> But I keep getting errors. Anybody know what I would have to do to get  
> it to work?
> 
> Help is greatly appreciated!
> 
> >

–  
Terry (TAD) Donaghe  
[http://tadspot.tumblr.com](http://tadspot.tumblr.com)

---

<div class="post-metadata">

**Author:** ![noooooo10](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/35a633/32.png) [@noooooo10](https://www.ruby-forum.com/u/noooooo10)\
**Post date:** [May 10, 2007, 4:45pm UTC](https://www.ruby-forum.com/t/link-to/103762/3 "2007-05-10T16:45:30Z")

</div>

Thanks very much for you help.

Interestingly, I ordered the book last night anyway!

Look forward to using RoR, and thanks once again for your help!
