title: Rails 4.1 Mailer Previews and Devise custom emails
body: <p>I have a brand new Rails 4.1.1 app where I'm customizing the Devise emails. I want to have them displayed on the new Rails email preview feature so I did the following:</p>
  
  <p>1) Added the following snippet to my <code>config/development.rb</code> file:</p>
  
  <pre><code>config.action_mailer.preview_path = "#{Rails.root}/lib/mailer_previews"
  </code></pre>
  
  <p>2) Created my custom Devise email <code>UserMailer</code> in <code>app/mailers/user_mailer.rb</code>:</p>
  
  <pre><code>class UserMailer &lt; Devise::Mailer   
    helper :application # gives access to all helpers defined within `application_helper`.
    include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url`
  
    layout "notifications_mailer"
  end
  </code></pre>
  
  <p>3) Changed <code>config/initializers/devise.rb</code> to contain the following snippet:</p>
  
  <pre><code>config.mailer = 'UserMailer'
  </code></pre>
  
  <p>4) Added the class <code>UserMailerPreview</code> to <code>lib/mailer_previews</code> with the following content:</p>
  
  <pre><code>class UserMailerPreview &lt; ActionMailer::Preview
    def confirmation_instructions
      UserMailer.confirmation_instructions(User.first, {})
    end
  
    def reset_password_instructions
      UserMailer.reset_password_instructions(User.first, {})
    end
  
    def unlock_instructions
      UserMailer.unlock_instructions(User.first, {})
    end
  end
  </code></pre>
  
  <p>So far, so good. Looks like I've done everything right. But then I try to see the preview for the <code>confirmation_instructions</code> email at the /rails/mailers/user_mailer/confirmation_instructions route and I get the following error:</p>
  
  <pre><code>undefined method `confirmation_url' for #&lt;#&lt;Class:0x007fa02ab808e0&gt;:0x007fa030fb7e80&gt;
  </code></pre>
  
  <p>the code for my <code>confirmation_url.html.erb</code> template looks like this:</p>
  
  <pre><code>&lt;%= t("notifications.texts.greeting") + @user.display_name %&gt;,
  
  &lt;p&gt;You can confirm your account email through the link below:&lt;/p&gt;
  
  &lt;p&gt;&lt;%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token =&gt;  @token) %&gt;&lt;/p&gt;
  </code></pre>
  
  <p>What am I doing wrong? I guess it is something wrong with the way I call the <code>confirmation_url</code> method. Anyone can help me here?</p>