How do I defined a variable link_to to an external URL

It sounds like you are storing URLs without the http:// so they are being interpreted as relative URLs. You just need to do something like this:

link_to micropost.website, "http://#{micropost.website}"

or maybe add a full_url method to that model that adds it if it’s missing.

By the way, you can’t use @micropost in that partial because it doesn’t exist (you only have @microposts or micropost).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)