Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7535485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:18:46+00:00 2026-05-30T06:18:46+00:00

I am trying to put a Rails link_to statement inside a Mailer email that

  • 0

I am trying to put a Rails link_to statement inside a Mailer email that includes the full-path (ie – http://localhost/contacts/id/confirm). The link_to statement that I am trying works in my standard View in /pages/options, but not in the Mailer email.

Here is my /pages/options Controller code:

class PagesController < ApplicationController
    def options
    end
end

And here’s the pages/options View:

<div>
    <%= link_to "here", :controller => "contacts", :action => "confirm", 
    :only_path => false, :id => 17 %>
</div>

When I put this link into the following mailer (welcome_email.html.rb), I am getting the error below. Any help with this will be greatly appreciated.

<!DOCTYPE html>
<html>
<head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
    <%= link_to "here", :controller => "contacts", :action => "confirm",
     :only_path => false, :id => 17 %>
</body>
</html>

The error message:

RuntimeError in Contacts#create

Showing C:/Documents and Settings/Corey Quillen/My Documents/Dev/Dev    
Projects/my_project
Project/my_project/app/views/user_mailer/welcome_email.html.erb where line #7  
raised:

Missing host to link to! Please provide :host parameter or set  
default_url_options[:host]
Extracted source (around line #7):

4:     <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
5:   </head>
6:   <body>
7:     <%= link_to "here", :controller => "contacts", :action => "confirm", :only_path    
=> false, :id => 17 %>
8:   </body>
9: </html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:18:47+00:00Added an answer on May 30, 2026 at 6:18 am

    Because mailers aren’t run inside the response stack, they have no idea what host they were called from: that’s why you’re running into this error. It’s easy to fix, change the code to include the host:

    <%= link_to "here", :controller => "contacts", :action => "confirm",
    :only_path => false, :id => 17, :host => "example.com" %>
    

    You can also set the default host on a per-application basis inside of your application.rb (or any of your environments) by specifying this:

    config.action_mailer.default_url_options = { :host => "example.com" }
    

    For the full documentation on ActionMailer and why this problem occurs, check out the ActionMailer documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying put an if statement directly into a select field in rails, with
I'm trying to put some specs around a new rails 3 project I am
I am using jQuery with rails. I am trying to make a PUT request
I trying to put together an Android app that will take a picture and
I'm trying to put in an exception in my web.config so that one page
I'm trying to get my backbone associations working inside a rails app , and
I'm trying to get basic http authentication working on my Rails app. I'm offering
I am just trying to walk through this tutorial http://jimneath.org/2011/03/24/using-redis-with-ruby-on-rails.html#redis_and_rails And when I put
Ruby 1.8.7, Rails 2.3.11 I've been trying the answers that appear to be what
Rails 2.3.5 For a link_to image_tag', I've been trying to figure out how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.