How to “link_to” full path in rails 4?

懵懂的女人 提交于 2019-12-23 13:25:08

问题


This is the code i have

<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>

from the above <%= link_to "open your box", gig_path(@gig)

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. for reference i can do @gig.title,@gig.description and it works with no problem.


回答1:


To get the full URL, use gig_url(@gig) instead of gig_path(@gig).



来源:https://stackoverflow.com/questions/30606747/how-to-link-to-full-path-in-rails-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!