Ask A Question


You’re not receiving notifications from this thread.

Updated to Ruby 3.1.2, now targets in Stimulus Controllers not working

Erik Huang asked in Javascript

I am using Rails 6 and recently upgraded from Ruby 3.0.1 to 3.1.2. Since the upgrade for some reason, my reflexes are no longer working properly when invoked from stimulus controllers, as shown in profile-form#addTag():


import { Controller } from '@hotwired/stimulus';
import StimulusReflex from 'stimulus_reflex';

export default class extends Controller {
  connect() {

  getControllerByIdentifier(identifier) {
    return this.application.controllers.find((controller) => {
      return controller.context.identifier === identifier;

  beforeReflex(element, reflex) {

  afterReflex(element, reflex) {


import ApplicationController from './application_controller';

export default class extends ApplicationController {
  static targets = ['form'];

  connect() {

  addTag(event) {
    this.stimulate("ProfileForm#add_tag", this.formTarget);

ActionCable seems to be working properly, and when I console log in the stimulus callbacks, I can verify beforeReflex is returning but not afterReflex. This is only happening when I pass a stimulus data target in to this.stimulate() so:

this.stimulate( behaves as expected but this.stimulate(this.formTarget) does not.

Anyone happen across this issue before? I'd be happy to provide more context if needed.


Maybe not a good answer. I ran into a problem upgrading to 3.1.2 and just rolled back to 3.0.2. Not the same problem as yours. My thinking was I didn't need the latest and that eventually the problem would be fixed. And I was on Rails 7, so would assume fewer issues. My notes:

Downgraded to ruby-3.0.2 because of visit_Psych_Nodes_Alias': Cannot load database configuration: (Psych::BadAlias) error on launch (

Join the discussion
Create an account Log in

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

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

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