Closed tyler-wel closed 9 months ago
@tongueroo For the time being, I am needing to fork the repository and introduce the following changes.
jets/overrides/rails/common_methods.rb
def add_stage_name(url)
request ? Jets::Controller::Stage.add(request.host, url) : url
end
I have no idea if this is the "correct" way to go about fixing the issue, but it is working as intended for me.
This is no longer an issue I have reset password links in my app i throughly tested @tongueroo , this can be closed
Hovering over my confirm link you can see the url:
This is possible in Jets 5
https://blog.boltops.com/2023/12/05/jets-5-improvements-galore/
It was tested as part of testing Kingsman
https://docs.rubyonjets.com/docs/auth/kingsman/
URL helpers are available
Checklist
jets upgrade
command that makes this a simple task. There's also an Upgrading Guide: http://rubyonjets.com/docs/upgrading/My Environment
Expected Behaviour
Attempting to send an email containing a
link_to
element inside thehtlm.erb
file successfully sends via console or job.Current Behavior
ActionView::Template::Error (undefined method 'host' for nil:NilClass)
is raised. Error is originating fromlib/jets/overrides/rails/common_methods.rb:5:in 'add_stage_name'
. https://github.com/boltops-tools/jets/blob/master/lib/jets/overrides/rails/common_methods.rb#L5Step-by-step reproduction instructions
Run the following commands
Uncomment the following line in
development.rb
Ensure the generated mail can be delivered
Output
Inside
test_mail.html.erb
add alink_to
elementEnter the jets console and attempt to send again
Error Log
Note:
The same error occurs if the mailer is invoked from a job once deployed to AWS Lambda.
Code Sample
See the reproduction instructions. Only one comment is uncommented and a single block of code added to a generated
html.erb
The relevant code that is erroring: https://github.com/boltops-tools/jets/blob/master/lib/jets/overrides/rails/common_methods.rb#L5
Solution Suggestion
I am not so familiar with Jets, but am assuming this is happening due to the fact that the mail is being sent not via a request from a controller, but via the console or a job.
Commenting out the following line enables me to send emails from the console/job.