guizero
Joined 1/23/2021
guizero said almost 4 years ago on Hotwire :
I am following the tutorial and there are differences too.

I am on Rails 6.0.3.4 and Ruby 2.7.1. Hotwire 0.1.3

The the controllers folder was created inside `app/javascript`

My application.js looks like this

// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.

require("@rails/ujs").start()
require("@rails/activestorage").start()
require("channels")


// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)

import "controllers"

require("trix")
require("@rails/actiontext")

Everything went smooth until the StimulusJS part.

I am getting a:
Uncaught Error: Cannot find module 'controllers'

I have tried reinstalling stimulus-rails (rails stimulus:install) with no success.

guizero said almost 4 years ago on Hotwire :
 

I followed your other video, without success...

Just so you understand the steps I have followed.

Using Rails 6.1.1.1

```
rails new app
cd app
bundle install
bundle add hotwire-rails
rails hotwire:install
```

I am using rails with webpacker as default.

And then scaffolded a posts model. Just that.

When visiting localhost:3000/posts the error shows up

guizero said almost 4 years ago on Hotwire :
Thanks   

I have finally managed to make it work with webpacker.
The changes were:
Use: 
- rails webpacker:install:stimulus (which will add the controllers/index.js)
- rails stimulus:install:webpacker (to be sure)
- rails turbo:install:webpacker

On the layout, change `data-turbolink-track` to `data-turbo-track`:
<!DOCTYPE html>
<html>
  <head>
    <title>Fiio</title>
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>

    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbo-track': 'reload' %>
    <%= javascript_pack_tag 'application', 'data-turbo-track': 'reload' %>
  </head>

  <body>
    <%= yield %>
  </body>
</html>

and, finally, on the Stimulus side, as pointed out by RailsCod3rFuture, use `reset-form` instead of `reset_form` when calling the controller on Stimulus.

guizero said almost 4 years ago on Hotwire :
 

Just so you know, I'd opened an issue regarding the problem I was facing:
https://github.com/hotwired/stimulus-rails/issues/33#issuecomment-766373945 PR

A PR was raised and it was already merged into stimulus-rails.

Thanks for the help