Comments (9)
Cool, that is what exactly we need. I found this file here https://github.com/rails/webpacker/blob/v4.0.0/lib/install/examples/stimulus/controllers/index.js,
we can just place it in the controller directory and stimulus:install:webpacker
will handle it for us.
I will make a PR for this
from stimulus-rails.
Is there a controllers directory anywhere in your application? It may be that Stimulus was installed into the asset pipeline, meaning that the controllers folder is in yours app/assets
folder. I believe that the error is saying that Webpack can't find the controllers folder in its load path.
from stimulus-rails.
Hey @jacobdaddario . Yes, the javascripts/controllers is there with the hello_world_controller.js
I believe that the imported controllers was coming from this gem. Do I have to create a controllers/index.js manually?
from stimulus-rails.
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
from stimulus-rails.
I have encountered the same problem and find the solution in hotwire's document
The path has modified to fit the directory hotwire auto-created.
import { Application } from "stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"
const application = Application.start()
const context = require.context("../controllers", true, /\.js$/)
application.load(definitionsFromContext(context))
from stimulus-rails.
Hey @kuei0221 , cool! I'd done the same to make it work. I just believe that this should be added to this gem, I mean, when using webpacker (currently default on rails apps) this index should be created as well.
Actually, when you run
rails webpacker:install:stimulus
The file is created.
from stimulus-rails.
I am happy to see that it was already merged =) @kuei0221
from stimulus-rails.
Ran into this issue when I added hotwire-rails and then ran the install script, Appears fixed in main
from when using stimulus-rails from GitHub. Hoping @dhh or friends can ship a new release soon so we don't need to use the gem from GitHub (and so hotwire-rails's gem will just work)
from stimulus-rails.
The README needs to be updated to reflect the new steps
from stimulus-rails.
Related Issues (20)
- Controllers written in Coffeescript? HOT 1
- why not auto "rails stimulus:manifest:update"
- Failing to register controllers does not bubble the error to handleError HOT 1
- stimulus-rails installation rails - undefined method Stimulus::Rails.application HOT 1
- manifest:update configuration for controller segmentation HOT 1
- Should controller names be registered as camelCase? HOT 2
- rails stimulus:manifest:update replacing our index.js configs HOT 1
- 404 on assets/stimulus-loading.js with config.assets.digest set to false HOT 11
- Mutation Observer not recognising DOM change when using Turbo Streams HOT 2
- Browser Back button is not working for some feature in stimulus HOT 2
- Console error with lazyLoadControllersFrom and external controller HOT 1
- Add typescript support for rails stimulus generator
- Action params not populating HOT 1
- Debugging `Failed to auto-load controller` ... `Unable to resolve specifier` HOT 2
- Error when passing JSON formatted data from rails to stimulus HOT 1
- Stimulus broken in Firefox 115+ with importmap-rails HOT 4
- Is it possible to use controllers stored in a GEM ?
- ActiveModel not working with value to Object HOT 2
- Add manual installation instructions to readme HOT 2
- Failed to autoload controller popper js HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stimulus-rails.