Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've found a way. I will think if I can find a better way without having to monkey patch stuff and having to chain it up the subdomain. </p> <p>Basically, I override the controller doing this:</p> <pre><code>class PasswordsController &lt; Devise::PasswordsController def create subdomain = request.subdomain @user = User.send_reset_password_instructions(params[:user].merge(subdomain: subdomain)) if successfully_sent?(@user) respond_with({}, :location =&gt; after_sending_reset_password_instructions_path_for(:user)) else respond_with(@user) end end end </code></pre> <p>Also, I had to monkey patch this methods on my user model:</p> <pre><code>def send_reset_password_instructions(subdomain) generate_reset_password_token! if should_generate_reset_token? send_devise_notification(:reset_password_instructions, subdomain: subdomain) end def self.send_reset_password_instructions(attributes={}) recoverable = find_or_initialize_with_errors(reset_password_keys, attributes, :not_found) recoverable.send_reset_password_instructions(attributes[:subdomain]) if recoverable.persisted? recoverable end </code></pre> <p>And finally, I had to monkey patch <code>devise_mail</code> methods, which lives inside Devise.</p> <pre><code> Devise::Mailer.class_eval do def devise_mail(record, action, opts={}) initialize_from_record(record) initialize_subdomain(opts.delete(:subdomain)) # do this only if the action is to recover a password. mail headers_for(action, opts) end def initialize_subdomain(subdomain) @subdomain = instance_variable_set("@subdomain", subdomain) end end </code></pre> <p>Doing this, the <code>@subdomain</code> variable appeared on the mailer template. I'm not happy with this solution, but this is a starting point. I will think on any improvements on it. </p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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