From 62e951e300a90e21c7268dc8e557d22a285fdaf3 Mon Sep 17 00:00:00 2001 From: Max Wofford Date: Fri, 7 Mar 2025 18:10:32 -0500 Subject: [PATCH] Add letter-opener --- Gemfile | 4 ++++ Gemfile.lock | 15 +++++++++++++++ config/routes.rb | 11 +++++++++++ 3 files changed, 30 insertions(+) diff --git a/Gemfile b/Gemfile index cd20721..909d808 100644 --- a/Gemfile +++ b/Gemfile @@ -77,6 +77,10 @@ group :development do # Use console on exceptions pages [https://github.com/rails/web-console] gem "web-console" + # Preview emails in the browser [https://github.com/ryanb/letter_opener] + gem "letter_opener" + gem "letter_opener_web", "~> 3.0" + # Rack Mini Profiler [https://github.com/MiniProfiler/rack-mini-profiler] gem "rack-mini-profiler" # For memory profiling via RMP diff --git a/Gemfile.lock b/Gemfile.lock index 23f095c..6d7162b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -115,6 +115,8 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + childprocess (5.1.0) + logger (~> 1.5) concurrent-ruby (1.3.5) connection_pool (2.5.0) crass (1.0.6) @@ -208,6 +210,17 @@ GEM thor (~> 1.3) zeitwerk (>= 2.6.18, < 3.0) language_server-protocol (3.17.0.4) + launchy (3.1.1) + addressable (~> 2.8) + childprocess (~> 5.0) + logger (~> 1.6) + letter_opener (1.10.0) + launchy (>= 2.2, < 4) + letter_opener_web (3.0.0) + actionmailer (>= 6.1) + letter_opener (~> 1.9) + railties (>= 6.1) + rexml lint_roller (1.1.0) llhttp-ffi (0.5.0) ffi-compiler (~> 1.0) @@ -472,6 +485,8 @@ DEPENDENCIES importmap-rails jbuilder kamal + letter_opener + letter_opener_web (~> 3.0) memory_profiler paper_trail pg diff --git a/config/routes.rb b/config/routes.rb index 6c172a9..75a7909 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,6 +7,12 @@ class AdminConstraint end end +class DevelopmentConstraint + def self.matches?(request) + Rails.env.development? + end +end + Rails.application.routes.draw do constraints AdminConstraint do mount Avo::Engine, at: Avo.configuration.root_path @@ -16,6 +22,11 @@ Rails.application.routes.draw do end get "/stop_impersonating", to: "sessions#stop_impersonating", as: :stop_impersonating + constraints DevelopmentConstraint do + # Preview emails in the browser [https://github.com/ryanb/letter_opener] + mount LetterOpenerWeb::Engine, at: "/letter_opener", as: :letter_opener + end + # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. get "up" => "rails/health#show", as: :rails_health_check