title: Ruby/Rails: How do you customize the mailer templates of Devise?
body: <p>I've installed Devise for my Rails app (3.0.1) and it's mostly working. I just <em>can't seem customize the mailer views</em>.</p>
  
  <ul>
  <li>My user model is "User".</li>
  <li>The devise controllers (which I needed to override so I could tell the controllers what layout file to use) are in <code>app/controllers/users/</code>, like so <code>app/controllers/users/sessions_controller.rb</code></li>
  <li>The devise views (which I've edited) are in <code>app/views/users/</code> like so <code>app/views/users/registrations/new.html.haml</code></li>
  <li>Here's the devise portion of my routes file:</li>
  </ul>
  
  <pre>
      devise_for :users, :controllers => { 
        :sessions => "users/sessions", 
        :registrations => "users/registrations", 
        :passwords => "users/passwords", 
        :confirmations => "users/confirmations", 
        :unlocks => "users/unlocks"
      } do
        get "/login" => "devise/sessions#new"
        get "/logout" => "devise/sessions#destroy"
      end
  </pre>
  
  <p>Everything above works, at least. However, when sending mail, <strong>the templates that Devise seems to use aren't the ones I've edited at <code>app/views/users/mailer/</code></strong>. Devise still seems to pickup the default one (as if I've never edited the files). I'm guessing that Devise still uses the files in the gem.</p>
  
  <p>In case it helps, here's the Cucumber error:</p>
  
  <pre><code>Feature: Manage accounts
    In order to manage accounts
    users
    should be able to signup
  
    # By default, www.example.com is the host when testing.
    # This is a problem because when our site searches for the domain example.com, it cant find any.
    # Therefore we must either set our testing domain to one of our choosing (and mention that in the routes), or create a domain example.com
    # I prefer the first option.
    Scenario: Signing up and resetting the password                                                                      # features/manage_accounts.feature:10
      Given I am on the login page                                                                                       # features/step_definitions/web_steps.rb:19
      When I follow "Sign up"                                                                                            # features/step_definitions/web_steps.rb:33
      And I fill in "Login" with "bobrobcom"                                                                             # features/step_definitions/web_steps.rb:39
      And I fill in "Email" with "my@email.com"                                                                          # features/step_definitions/web_steps.rb:39
      And I fill in "Password" with "123456"                                                                             # features/step_definitions/web_steps.rb:39
      And I fill in "Password confirmation" with "123456"                                                                # features/step_definitions/web_steps.rb:39
      And I press "Sign up"                                                                                              # features/step_definitions/web_steps.rb:27
      Then I should see "Your account has been created. A confirmation was sent to your e-mail."               # features/step_definitions/web_steps.rb:107
      And I should receive an email                                                                                      # features/step_definitions/email_steps.rb:51
      When I open the email                                                                                              # features/step_definitions/email_steps.rb:72
      Then I should see "Welcome bobrobcom!" in the email body                                                           # features/step_definitions/email_steps.rb:96
        expected "&lt;p&gt;Welcome my@email.com!&lt;/p&gt;\n\n&lt;p&gt;You can confirm your account through the link below:&lt;/p&gt;\n\n&lt;p&gt;&lt;a href=\"http://stils.dev/users/confirmation?confirmation_token=d9ZXliqfTArb2cNmwPzL\"&gt;Confirm my account&lt;/a&gt;&lt;/p&gt;\n" to include "Welcome bobrobcom!" (RSpec::Expectations::ExpectationNotMetError)
        ./features/step_definitions/email_steps.rb:97:in `/^(?:I|they) should see "([^"]*?)" in the email body$/'
        features/manage_accounts.feature:21:in `Then I should see "Welcome bobrobcom!" in the email body'
      When I follow "Confirm my account"                                                                                 # features/step_definitions/web_steps.rb:33
      Then I should see "Your account was successfully confirmed. You are now signed in."                                # features/step_definitions/web_steps.rb:107
      When I log out                                                                                                     # features/step_definitions/user_steps.rb:9
      And I go to the reset password page                                                                                # features/step_definitions/web_steps.rb:23
      And I fill in "Email" with "my@email.com"                                                                          # features/step_definitions/web_steps.rb:39
      And I press "Send me reset password instructions"                                                                  # features/step_definitions/web_steps.rb:27
      Then I should see "You will receive an email with instructions about how to reset your password in a few minutes." # features/step_definitions/web_steps.rb:107
      And I should receive an email                                                                                      # features/step_definitions/email_steps.rb:51
      When I open the email                                                                                              # features/step_definitions/email_steps.rb:72
      Then I should see "Hello bobrobcom!" in the email body                                                             # features/step_definitions/email_steps.rb:96
      When I follow "Change my password" in the email                                                                    # features/step_definitions/email_steps.rb:166
      Then I should see "Set your new password"                                                                          # features/step_definitions/web_steps.rb:107
  
  Failing Scenarios:
  cucumber features/manage_accounts.feature:10 # Scenario: Signing up and resetting the password
  </code></pre>
  
  <p>And app/views/users/confirmation_instructions.erb:</p>
  
  <pre><code>&lt;p&gt;Welcome &lt;%= @resource.login %&gt;!&lt;/p&gt;
  
  &lt;p&gt;You can confirm your account through the link below:&lt;/p&gt;
  
  &lt;p&gt;&lt;%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token =&gt; @resource.confirmation_token) %&gt;&lt;/p&gt;
  </code></pre>
  
  <p>Also, if it helps, here are the controllers I've overridden:</p>
  
  <pre><code>| | |~users/
  | | | |-confirmations_controller.rb
  | | | |-passwords_controller.rb
  | | | |-registrations_controller.rb
  | | | |-sessions_controller.rb
  | | | `-unlocks_controller.rb
  </code></pre>
  
  <p>How do I fix this issue?</p>
  
  <p>Thanks!</p>