Emails fail to send - bad url_for generation.
Closed this issue · 2 comments
I've tried a lot of different methods of re-identifying the route to rails as well, but I keep getting the same failure on a vanilla installation of ahoy_email
- the app is incredibly simple at this point, essentially just a skeleton Rails 5.1.5 app with Devise 4.4.1 installed.
ActionController::UrlGenerationError: No route matches {:action=>"open", :controller=>"ahoy/messages", :format=>"gif", :id=>nil}
I don't think it should matter, but I have only tested this so far on trying to track the Devise-sent emails (via an ActiveJob queue), which is the job raising this exception.
Update: the issue seems to be related to url_for
being invoked with a nil
id, causing the matchers to pass over the actual route. Moving into troubleshooting why ahoy_message.token
would be returning nil
in the track_open
call now.
[5] pry(main)> AhoyEmail::Engine.routes.url_helpers.url_for(:action=>"open", :controller=>"ahoy/messages", :format=>"gif", :id=>nil, host: 'a')
ActionController::UrlGenerationError: No route matches {:action=>"open", :controller=>"ahoy/messages", :format=>"gif", :id=>nil}
from [REDACTED]/2.4.2/lib/ruby/gems/2.4.0/gems/actionpack-5.1.5/lib/action_dispatch/journey/formatter.rb:55:in `generate'
[6] pry(main)> AhoyEmail::Engine.routes.url_helpers.url_for(:action=>"open", :controller=>"ahoy/messages", :format=>"gif", :id=>"7", host: 'a')
=> "http://a/ahoy/messages/7/open.gif"
I got this fixed by addressing an incorrect assumption in my migration that I could switch the message token to be a UUID. Cleaning that up fixed the url_for
generation, and now we're good to go!