stimulusreflex / stimulus_reflex

Build reactive applications with the Rails tooling you already know and love.
https://docs.stimulusreflex.com
MIT License
2.28k stars 172 forks source link

Setup & Quick Start guide from scratch results in showstopping error #153

Closed bbugh closed 4 years ago

bbugh commented 4 years ago

Bug Report

Describe the bug

Following the "Setup" and "Quick Start" guide process exactly results in breaking socket is undefined error in the JS console in Firefox, andUncaught TypeError: Cannot read property 'removeEventListener' of undefined` in Chrome (both raised by same line of code).

It looks like StimulusReflex is looking for something on the ActionCable JS object that doesn't exist. Is this because of #132 maybe? Or is there another dependency or import missing from the instructions?

To Reproduce

Following the setup guide exactly and then using the sample code results in socket is undefined in the JavaScript console.

# these are the setup instructions
rails new myproject --webpack=stimulus # Rails 6.0.2.2
cd myproject
bundle add stimulus_reflex
bundle exec rails stimulus_reflex:install
# make a controller
bin/rails g controller pages index

Add the sample code from the quickstart guide to the pages/index.html.erb.

bin/webpack-dev-server
bin/rails s

Finally, load localhost:3000/pages/index and observe that the JavaScript console says socket is undefined in Firefox (or the Chrome error).

Expected behavior

There's no error and it loads fine.

Versions

StimulusReflex

External tools

Browser

bbugh commented 4 years ago

This looks like it is probably a duplicate of #151 given that it is the same error.