如何"link_to"轨道4的完整路径? [英] How to "link_to" full path in rails 4?
本文介绍了如何"link_to"轨道4的完整路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我拥有的代码
<a <%= link_to "open your box", gig_path(@gig), class: "mcnButton", target: "_blank", style: "font-weight: bold;letter-spacing: 0px;line-height: 100%;text-align: center;text-decoration: none;color: #FFFFFF;"%></a>
上面<%= link_to "open your box", gig_path(@gig)
注意gig_path(@gig)
它为我提供了URL http://gigs/3
,并且运行良好,它发现了我需要的id:3
演出,但问题是它没有提供完整的URL
Note gig_path(@gig)
it gives me the url http://gigs/3
,and it works well,it found the gig i need with id:3
the problem is that it doesn't provide the full url like this
http://example.com/gigs/3
P.S.作为参考,我可以做@gig.title
,@gig.description
,并且没有问题.
http://example.com/gigs/3
P.S. for reference i can do @gig.title
,@gig.description
and it works with no problem.
推荐答案
要获取完整的URL,请使用gig_url(@gig)
而不是gig_path(@gig)
.
To get the full URL, use gig_url(@gig)
instead of gig_path(@gig)
.
这篇关于如何"link_to"轨道4的完整路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文