letter_opener_web icon indicating copy to clipboard operation
letter_opener_web copied to clipboard

Add pluggable storage backend support (Enabling Redis/S3 storage)

Open thisduck opened this issue 2 months ago • 2 comments

Adds support for pluggable storage backends via configuration, enabling external gems like letter_opener_web-redis and letter_opener_web-s3 to provide alternative storage implementations.

Changes

  • Added LetterInterface module defining the contract for storage backends
  • Added letter_class configuration option (defaults to LetterOpenerWeb::Letter)
  • Updated LettersController to use configured letter_class instead of hardcoded Letter
  • Updated Letter to implement send_attachment method for consistency
  • Updated README with information about Redis backend for Heroku/multi-machine environments

Usage

Storage backends can now be swapped via configuration:

  require 'letter_opener_web_redis'

  LetterOpenerWeb.configure do |config|
    config.letter_class = LetterOpenerWeb::RedisLetter
    config.redis_url = ENV['REDIS_URL']
    config.redis_namespace = 'letter_opener'
  end

  config.action_mailer.delivery_method = :letter_opener_web_redis

Redis storage available here: https://github.com/WizaCo/letter_opener_web-redis S3: https://github.com/WizaCo/letter_opener_web-s3

thisduck avatar Oct 26 '25 03:10 thisduck

Based on feedback in: https://github.com/fgrehm/letter_opener_web/pull/129#issuecomment-2111391590

thisduck avatar Oct 26 '25 03:10 thisduck

@fgrehm @stevenharman thoughts on this? As it addresses #35 and the feedback in #129.

Thanks!

thisduck avatar Oct 27 '25 14:10 thisduck