siamii
siamii

Reputation: 24094

Absolute url in ActionMailer view

I have an asynchronous job that sends an email to the user when it completes. I'm testing the send email function with rspec.

In environments/test.rb I have this line

config.action_mailer.default_url_options = { :host => 'localhost:3000' }

In the action mailer view I have this line,

= link_to(@submission.title, @submission, {:only_path => false})

This generates a relative url

<a href="/submissions/1" only_path="false">Test Submission 1</a>

What I need is

<a href="http://localhost:3000/submissions/1">Test Submission 1</a>

Upvotes: 3

Views: 1643

Answers (1)

Veraticus
Veraticus

Reputation: 16064

Call the named route directly instead of allowing Rails to generate it for you. So turn your link into this:

= link_to(@submission.title, submission_url(@submission))

Upvotes: 4

Related Questions