Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The main solution described in the Devise wiki doesn’t work for setting arbitrary subdomains and is a problem if you’re triggering generation of email during a request in one subdomain (or the root domain of your application) and want the links in the email to reference a different subdomain.</p> <p>The generally accepted way to make it work is to give the <code>url_for</code> helper a <code>:subdomain</code> option.</p> <pre><code># app/helpers/subdomain_helper.rb 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) &amp;&amp; options.has_key?(:subdomain) options[:host] = with_subdomain(options.delete(:subdomain)) end super end end </code></pre> <p>The next step is crucial and I suspect it is where a lot of people get tripped up (I know I did). Make sure that Devise mixes your new subdomain helper into its mailer objects by adding the following code to <code>config/application.rb</code></p> <pre><code> config.to_prepare do Devise::Mailer.class_eval do helper :subdomain end end </code></pre> <p>Now when you do a <code>link_to</code> in your Devise mailer template, you can easily specify a <code>:subdomain</code> option.</p> <pre><code>link_to 'Click here to finish setting up your account on RightBonus', confirmation_url(@resource, :confirmation_token =&gt; @resource.confirmation_token, :subdomain =&gt; @resource.subdomain) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload