views:

59

answers:

2

I am new to rails so sorry for stupid questions. I have created section of the website I am working on where the client can post news about their clients. In the entry view I collect title:string content:text and link:string. How do I render the link:string as an actual link in the show and index views.

A: 

you're looking for the link_to helper. In your view you would do something like:

<%= link_to "some text", "http://example.com" %>
Jeff Paquette
I am trying to render the data that was entered in the database as text. For instance, when adding a new news story, the client can add a link. The add the link by simply typing "html://example.com" into the field that that gets submitted into the link:string column. Then when I display that link on the show.html.erb and the index.html.erb pages it shows up as a link. Does that make sense?
bgadoci
`<%= link_to nil, @news_post.link %>`
mckeed
A: 

You should be careful about taking user input without sanitizing it. You can open yourself up to XSS attacks and the like (http://en.wikipedia.org/wiki/Cross-site%5Fscripting). I would look at something like http://railspikes.com/2008/1/28/auto-escaping-html-with-rails as part of your project.

Jason Yanowitz