simonrohrbach
simonrohrbach

Reputation: 522

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?

Upvotes: 0

Views: 1254

Answers (3)

Alexandr Yakubenko
Alexandr Yakubenko

Reputation: 564

You can use this form:

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

Upvotes: 2

Someth Victory
Someth Victory

Reputation: 4559

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

Upvotes: 0

Related Questions