Reputation: 522
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
Reputation: 564
You can use this form:
get "settings/redirect" => "settings#redirect", :as => :settings_redirect
Upvotes: 2
Reputation: 4559
match "/settings_redirect" => "settings#redirect", :via => "get"
Upvotes: 0
Reputation: 4097
Check out this documentation, http://guides.rubyonrails.org/action_mailer_basics.html#generating-urls-in-action-mailer-views
Upvotes: 0