ActionMailer doesn't recognise route

I have a route called "settings_redirect", which I've defined as follows:

routes.rb

match "/settings/redirect" => "settings#redirect", :via => "get"

I want to link to this route in an email template:

mymail.html.erb

<%= link_to "Manage Settings", settings_redirect_url %>

Yet, when I get ActionMailer to send the email, I get the error

{undefined local variable or method `settings_redirect_url' for #<#:0x007ffa1153de38>

The same link works completely fine in any regular view, just not when I try to send it in an email. All other links in the same template don't cause any trouble either.

Any ideas as to what could cause the error?

Answers


match "/settings_redirect" => "settings#redirect", :via => "get"

You can use this form:

get "settings/redirect" => "settings#redirect", :as => :settings_redirect

Check out this documentation, http://guides.rubyonrails.org/action_mailer_basics.html#generating-urls-in-action-mailer-views


Need Your Help

Google maps containsLocation on android

android google-maps gps location

I'm writing an app that needs to determine whether a user falls within one of several defined zones (based on gps location).