Configure letter opener

This commit is contained in:
Jorge Manrubia
2025-08-26 10:21:13 +02:00
parent b911a12833
commit 218519d075
6 changed files with 45 additions and 2 deletions
+1
View File
@@ -60,6 +60,7 @@ group :development, :test do
gem "bundler-audit", require: false
gem "brakeman", require: false
gem "rubocop-rails-omakase", require: false
gem "letter_opener"
end
group :test do
+9
View File
@@ -276,6 +276,8 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
childprocess (5.1.0)
logger (~> 1.5)
chunky_png (1.4.0)
concurrent-ruby (1.3.5)
connection_pool (2.5.3)
@@ -342,6 +344,12 @@ GEM
jwt (3.1.2)
base64
language_server-protocol (3.17.0.5)
launchy (3.1.1)
addressable (~> 2.8)
childprocess (~> 5.0)
logger (~> 1.6)
letter_opener (1.10.0)
launchy (>= 2.2, < 4)
lint_roller (1.1.0)
logger (1.7.0)
loofah (2.24.1)
@@ -611,6 +619,7 @@ DEPENDENCIES
importmap-rails
jbuilder
kamal!
letter_opener
lexxy!
mission_control-jobs
mocha
+13
View File
@@ -63,6 +63,19 @@ A typical scenario is making modifications LLM prompts. You need to:
Notice that if you pass changing data to the prompt, this mechanism won't work. E.g: if you pass data timestamps.
You need to make sure those timestamps are always the same across executions.
### Outbound Emails
#### Development
You can view email previews at http://know-it-all.localhost:3005/rails/mailers.
You can enable or disable [`letter_opener`](https://github.com/ryanb/letter_opener) to
open sent emails automatically with:
bin/rails dev:email
Under the hood, this will create or remove `tmp/email-dev.txt`.
## Environments
Fizzy is deployed with Kamal. You'll need to have the 1Password CLI set up in order to access the secrets that are used when deploying. Provided you have that, it should be as simple as `bin/kamal deploy` to the correct environment.
+6 -2
View File
@@ -72,8 +72,12 @@ Rails.application.configure do
# Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = true
# Allow all hosts in development
config.hosts = nil
if Rails.root.join("tmp/email-dev.txt").exist?
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.perform_deliveries = true
else
config.action_mailer.raise_delivery_errors = false
end
config.hosts = %w[ fizzy.localhost localhost 127.0.0.1 ]
View File
+16
View File
@@ -0,0 +1,16 @@
namespace :dev do
desc "Toggle using Letter Opener to preview emails"
task :email do
file_path = Rails.root.join("tmp", "email-dev.txt")
if File.exist?(file_path)
File.delete(file_path)
puts "Letter Opener turned off"
else
FileUtils.touch(file_path)
puts "Letter Opener turned on"
end
%x(bin/rails restart)
end
end