title: "undefined method" on custom helper method
body: <p>I have the following custom route in my <em>routes.rb</em> file:</p>
  
  <pre><code>match '/security_users/:id/email_confirmation/:activation_code' =&gt; 'email_confirmation#new'
  </code></pre>
  
  <p>and want to create custom helper that generate the path above for specified <em>SecurityUser</em>. In my application_controler.rb file I have the method above:</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
  
    protect_from_forgery
  
    private
  
      def email_confirmation_path(security_user)
        "/security_users/#{security_user.id}/email_confirmation/#{security_user.activation_code}"
      end
  
      helper_method :email_confirmation_path
  
  end
  </code></pre>
  
  <p>But when I call it in my /views/security_user_mailer/email_confirmation.text.erb template like this:</p>
  
  <pre><code>&lt;%= email_confirmation_path(@security_user) %&gt;
  </code></pre>
  
  <p>I get the following error:</p>
  
  <blockquote>
    <p>NoMethodError at /security_users undefined method
    `email_confirmation_path' for #&lt;#:0x6340ff53></p>
  </blockquote>
  
  <p>Could you advice?</p>
  
  <p>EDIT:</p>
  
  <p>Below you can find the process workflow:</p>
  
  <p>First, when user is created the following line is executed </p>
  
  <pre><code>@security_user.send_email_confirmation
  </code></pre>
  
  <p>The method above is defined in the object model file like follows:</p>
  
  <pre><code>def send_email_confirmation
    SecurityUserMailer.email_confirmation(self).deliver
  end
  </code></pre>
  
  <p>Then in the mailer controller, the method below is invoked:</p>
  
  <pre><code>def email_confirmation(security_user)
    @security_user = security_user
    mail to: security_user.email, subject: 'Account Created'
  end
  </code></pre>
  
  <p>The previous method is using my template in which I need to call the custom path generator method:</p>
  
  <pre><code>&lt;%= email_confirmation_path(@security_user) %&gt;
  </code></pre>
  
  <p>but I get error that it is undefined.</p>