ryanb / letter_opener

Preview mail in the browser instead of sending.
MIT License
3.73k stars 238 forks source link

Fix duplication of Rails tasks #200

Closed zarqman closed 2 years ago

zarqman commented 2 years ago

The rails middleware task lists all middleware twice when using letter_opener 1.8.0.

I believe this might be caused by the Rails tasks being loaded twice, the extra loading of which is triggered by the use of require 'rails/tasks' in letter_opener.rake. Whether that's the correct explanation, removing that require resolves the issue.

This PR reworks the task setup to avoid needing the excess require while still chaining to tmp:clear.

Confirmed on Rails 7.0.2.x, but guessing it happens on earlier versions as well.

nashby commented 2 years ago

@zarqman thanks!

tiagotex commented 2 years ago

We have updated our app to 1.8.0 and we see an error while running some unrelated tasks: Don't know how to build task 'tmp:clear' (See the list of available tasks with 'rails --tasks')

I've confirmed this is no longer the case with this fix (main branch).

@nashby could you cut a patch release with this fix?

nashby commented 2 years ago

@tiagotex 1.8.1 has been released