'Rails.fire' in Stimulus controller not working with Rails 6.1 defaults

Hoping someone can help me this. I have a Stimulus (2.0) controller that updates the database on a focusout event (see simplified version below). I’ve been having problems with this since upgrading to Rails 6.1. If I use config.load_defaults 6.0 in my application.rb file, it performs as expected, but when I switch to config.load_defaults 6.1 it no longer works (though I don’t have any issue with database updates via the Rails controllers). The event listener is still triggering as expected, but it doesn’t seem like Rails.fire is doing anything.

This may be strictly a Rails issue but I was hoping someone here might have an idea what’s causing it. I’m not really sure how to go about debugging this.

import { Controller } from "stimulus"
import Rails from "@rails/ujs";

export default class extends Controller {
    static targets = ["title", "chapterForm"]

    connect() {
        let title = this.titleTarget;
        let chapterForm = this.chapterFormTarget;

        title.addEventListener('focusout', () => {
            Rails.fire(chapterForm, 'submit')

1 Like

Never mind, I figured it out. Has nothing to do with Stimulus; it’s related to this not-so-well-publicized change in Rails config defaults:


I have the same problem.

Wouldn’t we expect Rails.fire to submit the form as a HTML request with remote forms disabled?

I don’t understand why Rails.fire would seem to take no action.

Six months later, after spending a few days trying to figure out while Rails.fire was not working and a new rails application with code I copied form and upgraded rails 6.1 application I find this.

I swear I search the web and here for the problem but did not find anything until I started a new post here.


The config option is not even in a the new app. You have to user remote:true

1 Like