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.

Mike McCallen
  • 307
  • 1
  • 14

1 Answers1

5

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

neuronaut
  • 2,689
  • 18
  • 24
  • yes it did work in production,i just checked...but this is very strange instead of going to my custom domain name www.example.com/gigs/3 it goes to my www.herokuapp/gigs/3 ,but to the right one.why is that? – Mike McCallen Jun 02 '15 at 21:30
  • That's because Rails has no way to reliably figure out on its own what your host name is. Thus, you need to tell it what you want to use by setting the default. See http://stackoverflow.com/questions/2660172/how-do-i-set-default-host-for-url-helpers-in-rails for details. – neuronaut Jun 02 '15 at 21:32
  • the problem,was that i had a 'config.action_mailer.default_url_options' in production.rb that was redirecting to the heroku url) – Mike McCallen Jun 02 '15 at 22:05