nickjj / docker-rails-example

A production ready example Rails app that's using Docker and Docker Compose.
MIT License
941 stars 185 forks source link

App insists on trying to connect to `ws://localhost:8000/cable` when using Hotwire #58

Closed partydrone closed 8 months ago

partydrone commented 1 year ago

Following a screencast on how to use Hotwire in Rails and using this project as a starting point, after creating a basic Tweet scaffold and hooking it up using turbo_stream_from and turbo_frame_tag elements, etc., I noticed that the page insists on trying to connect to ws://localhost:8000/cable in spite of the configuration in application.rb.

I tried to identify the cause of the issue and have thus far been unsuccessful. Maybe you will have some idea what's going on?

nickjj commented 1 year ago

Hi,

In the application.rb file try replacing this:

    config.action_cable.mount_path = nil

With this:

    config.action_cable.mount_path = "/cable"

That's still going to use the built-in Action Cable server but it should at least let you get going for now.

I'd have to dig into why it's not using the custom URL endpoint in more detail. Feel free to look into this too!

nickjj commented 8 months ago

This is fixed thanks to this PR: https://github.com/nickjj/docker-rails-example/pull/71