bgadoci
bgadoci

Reputation: 6493

Rendering field data as a link in Ruby on Rails

Ok, I think this is probably an easy question but for the life of my I can't figure it out. I have created a table called ugtags and in that table I have two columns (beyond the basics), 'name' and 'link'.

I am trying to allow a user to add a link to a page. Ideally they would enter the link title (name) and the url (link) and in the view it would display the title as a link to the url that was entered in the link column.

I there a way to do it by simply affecting the <%= link_to h(ugtag.name) %> code?

Upvotes: 1

Views: 82

Answers (1)

Greg Campbell
Greg Campbell

Reputation: 15302

You should just be able to do:

<%= link_to h(ugtag.name), ugtag.link %>

See the documentation for all of the relevant options.

Upvotes: 2

Related Questions