RAILS 链接到外部站点,url 是用户表的属性,如:@users.website [英] RAILS link_to external site, url is attribute of user table, like: @users.website
问题描述
我正在开发一个允许用户创建帐户的网站.创建用户时的属性之一是用户个人网站.当我尝试像这样使用用户网站时:
<%= link_to @user.site, @user.url %>
生成的url为:http://0.0.0.0:3000/www.userswebsite.com
我认为这是因为 link_to 的@user 部分...但是我怎样才能让它链接到 www.userwebsite.com ?
看起来您需要在链接上粘贴协议.例如.您的数据库中有 www.userswebsite.com,它应该是 http://www.userswebsite.com>
I'm working on a website that allows users to create an account. One of the attributes when creating a user is a users personal website. When I try to use the users website like this:
<%= link_to @user.site, @user.url %>
The url that gets generated is: http://0.0.0.0:3000/www.userswebsite.com
I think this is because of the @user part of the link_to... but how can I get this to link to www.userwebsite.com ?
Looks like you need to stick the protocol on your link. E.g. you have www.userswebsite.com in your database, it should be http://www.userswebsite.com
这篇关于RAILS 链接到外部站点,url 是用户表的属性,如:@users.website的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!