Link_to


#1

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!


#2

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 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


#3

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!