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