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

  • SEARCH
  • Home
  • 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 7968829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:08:22+00:00 2026-06-04T07:08:22+00:00

I have app with domain ‘www.mysite.com’ which is hosting Drupal and ‘app.mysite.com’ hosting Rails

  • 0

I have app with domain ‘www.mysite.com’ which is hosting Drupal and ‘app.mysite.com’ hosting Rails app.

I have situation where the devise mailer url points to ‘www.mysite.com’ instead of ‘app.mysite.com’.

In devise.rb, I’ve settings as shown below:

config.mailer = "Devise::Mailer"
ActionMailer::Base.default_url_options = { :host => 'app.mysite.com' }

And in production.rb:

config.action_mailer.default_url_options = { :host => 'app.mysite.com' } 
ActionMailer::Base.smtp_settings = 
{
  :address   => 'smtp.sendgrid.net',    # SendGrid SMTP server
  :domain    => 'mysite.com',           # SendGrid account domain name 
  :user_name => 'username',             # SendGrid user name
  :password  => 'password',             # SendGrid password
  :enable_starttls_auto => true,
  :port => 587, 
  :authentication => :plain,
}

In views/devise/mailer/reset_password_instructions.html.erb, confirmation link looks something as shown below:

<%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %>

It successfully sends the email after clicking forgot password link and works like charm on localhost but the url host points to www.mysite.com instead of app.mysite.com and throws 404 error.

How can I point it to right host?

  • 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-06-04T07:08:23+00:00Added an answer on June 4, 2026 at 7:08 am

    I made it working after looking through the code which is described in devise wiki for sending email using subdomain helper method.

    module SubdomainHelper
      def with_subdomain(subdomain)
        subdomain = (subdomain || "")
        subdomain += "." unless subdomain.empty?
        host = Rails.application.config.action_mailer.default_url_options[:host]
        [subdomain, host].join
      end
    
      def url_for(options = nil)
       if options.kind_of?(Hash) && options.has_key?(:subdomain)
           options[:host] = with_subdomain(options.delete(:subdomain))
       end
       super
      end
    end
    

    All this helper method does is, check whether subdomain hash is present or not. If it’s present then, the method prepends subdomain before host and define new host name else default host name. I didn’t went through this process because for some reason it didn’t worked on rails 3.2 and I didn’t wanted to waste my time digging into it further due to strict time constraint.

    I thought wait, why don’t I just define the host name explicitly in mailer url_for method instead of traversing through all those methods.

    So, all what I did was, defined link_to in mailer with a hash key host and passed value as my subdomain. After that it worked like a charm :).

    In views/devise/mailer/reset_password_instructions.html.erb, confirmation link looks something as shown below:

    <%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token, :host => 'app.mysite.com') %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In google app engine can I have www.domain.com point to version X of my
I have an app in a domain like this http://www.example.com/ , but I need
I have been working on test framework, which creates a new app domain to
we have this application which uses cross app domain (2 app domains in the
I have just registered hostel6.in domain name with justhost.com, and I have facebook app
I have the following models. # app/models/domain/domain_object.rb class Domain::DomainObject < ActiveRecord::Base has_many :links_from, :class_name
I have created an app to standardize user creation for our AD domain. Now
I have followed the omniauth devise facebook app as explained by Ryan in episode
Let's say I have a non default app domain. I want to get a
I have a simple WCF service that is used for cross app-domain communication in

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.