Ask A Question


You’re not receiving notifications from this thread.

Stimulus JS Twitter UI: Part 1 Discussion

Is the source code for this (and other) episodes available? I am having some small problems following along.
Great episode! I did find some things didn't reproduce with Rails 5.2 etc.

Still pretty new to rails. What would happen during create if the failed validation? Trying to understand how you'd use create.js.erb to display the form with errors in create if it fails?


Great video Chris.

From Stimulus' docs, I found that we can refactor the controller class using javascript getter and setter methods, like so:

import { Controller } from "stimulus"

export default class extends Controller {
  static targets = [ "body", "characterCount" ]

  initialize() {
    this.characterCount = this.body.length

  update() {
    this.characterCount = this.body.length

  get body() {
    return this.bodyTarget.value

  set characterCount(value) {
    this.characterCountTarget.textContent = value

I am having an issue deploying a site with stimulus via capistrano. I get the error:

ModuleNotFoundError: Module not found: Error: Can't resolve './controllers' in '/home/deploy/site/releases/20190501124321/app/javascript/packs'

My directory is:

App/javascript/packs/controllers. Inside packs I have application.js which references ./controllers.

Any ideas why this is failing?

UPDATE: I figured it out. My controllers folder didn't have anything in it yet and was not syncing.


Hi Chris,

great video!

One thing I like to do these days is, instead of responding with a create.js.erb, catch the ajax:success event in the stimulus controller (possibly even by attaching it to document:

You don't get inline rendering of your Rails ivar this way, but you stay in the context of your controller and don't have to use that kind of "hacky" way of updating the form/character count, since you have access to this.element and your targets...


Great content Chris! I'm following but for some reason have been having problems to get the video to play. It's freezing right after I click the "Play" button

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,969+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.