Mike McCallen
Mike McCallen

Reputation: 307

How to "link_to" full path in rails 4?

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.

Upvotes: 4

Views: 2156

Answers (1)

neuronaut
neuronaut

Reputation: 2709

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

Upvotes: 5

Related Questions