开发者

Rendering field data as a link in Ruby on Rails

开发者 https://www.devze.com 2022-12-27 16:11 出处:网络
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

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) %>开发者_如何学Go code?


You should just be able to do:

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

See the documentation for all of the relevant options.

0

精彩评论

暂无评论...
验证码 换一张
取 消