开发者

How to get rails3 to do remote link using database info

开发者 https://www.devze.com 2023-04-05 13:48 出处:网络
the url comes from a database table, e.g. www.test.com. How do I get a working link if that url is stored in the database (as \'w开发者_如何学Goeb site\' column).

the url comes from a database table, e.g. www.test.com.

How do I get a working link if that url is stored in the database (as 'w开发者_如何学Goeb site' column).

I tried:

<%= link_to(company.web_site, company.web_site, :remote => true) %>

but I got http://localhost:3000/company_name.com and I can't seem to get rid of the localhost for the link.


Use <%= link_to(company.web_site, "http://#{company.web_site}", :remote => true) %> Hint it with "http://" string would do the trick.

Or prepend the url with http:// or https:// in your database at the fist place also be an alternative way.

0

精彩评论

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