RAILS 链接到外部站点,url 是用户表的属性,如:@users.website [英] RAILS link_to external site, url is attribute of user table, like: @users.website

查看:17
本文介绍了RAILS 链接到外部站点,url 是用户表的属性,如:@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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆