Writebook - Once

Bug - Book content doesnt update

Seems like the no content can be stored. Past the front page the app cant store text, images, or sections.
Went through the docs and the logs of the application.
Apparently there was this problem every time a user tried any type of text:

2025-03-14T17:30:19Z app[d8d9263b0d9458] qro [info]E, [2025-03-14T17:30:19.932188 #664] ERROR -- : [e67336a0-d267-45d1-83ad-c1ed63b19c29] [ActiveJob] Failed enqueuing Turbo::Streams::BroadcastJob to Resque(default): Redis::CannotConnectError (Connection refused - connect(2) for 127.0.0.1:6379 (redis://localhost:6379))
2025-03-14T17:30:19Z app[d8d9263b0d9458] qro [info]I, [2025-03-14T17:30:19.933385 #664]  INFO -- : [e67336a0-d267-45d1-83ad-c1ed63b19c29] Completed 500 Internal Server Error in 46ms (ActiveRecord: 1.0ms (6 queries, 0 cached) | GC: 0.0ms)
2025-03-14T17:30:19Z app[d8d9263b0d9458] qro [info]E, [2025-03-14T17:30:19.936366 #664] ERROR -- : [e67336a0-d267-45d1-83ad-c1ed63b19c29]

Trying to resolve this issue, I set up a new redis instance in fly (dashboard > upstash redis > new, then you click on the application and read the upstash dashboard to find the redis url) with the connection string redis://default:9XXXX@fly-writebook-test3-redis.upstash.io:6379. Then I looked at any mention of redis (like redis config) and went through the files of the application.

Added Redis Intializer

Added the following file into config > initializers > redis.rb

# config/initializers/redis.rb
require "redis"

redis_url = ENV.fetch("REDIS_URL") { "redis://localhost:6379" }
REDIS = Redis.new(url: redis_url)

# Configure Resque to use this Redis connection
Resque.redis = REDIS if defined?(Resque)

Changed the cable.yml file

# config/cable.yml
development:
  adapter: redis
  url: <%= ENV.fetch("REDIS_URL") %>

test:
  adapter: test

production:
  adapter: redis
  url: <%= ENV.fetch("REDIS_URL") %>
  channel_prefix: writebook_production

Then re-deployed with env variable REDIS_URL

  1. fly deploy
  2. fly secrets set REDIS_URL=redis://default:9XXXX@fly-writebook-test3-redis.upstash.io:6379
  3. fly launch

That solved the error.

If the error persist or you cant deploy try to edit the docker file

... other content
# Set production environment
ENV BUNDLE_DEPLOYMENT="1" \
    BUNDLE_PATH="/usr/local/bundle" \
    BUNDLE_WITHOUT="development:test" \
    RAILS_ENV="production" \
    PORT="8080" \
    REDIS_URL="redis://default:9XXXX@fly-writebook-test3-redis.upstash.io:6379"

...