Ask A Question


You’re not receiving notifications from this thread.

Primer on Rails 5.1's new UJS library Discussion

Hey Chris, thanks for this guided tour, very useful! Rails.ajax(...) will be super helpful.

I found some other changes in UJS behaviour since the rewrite, particularly in handleRemote's function call signature and in the parameters to ajax:success events. I've written my notes up here:


This was an enlightening episode. Thanks for digging into the source to show us what's going on behind the scenes.

While discussing `Rails.linkClickSelector`, you mentioned, "you could be able to append stuff and move stuff from it as necessary." I'd like to ask you about that.

I would like to build a "verify" dialog box for deleting certain resources in one of my projects. The dialog box would work like the github dialog box for deleting a repo, in that you have to type the name of the resource in order to delete it. The idea is to make it impossible to inadvertently delete a resource.

The syntax I envision would be something like this:

link_to 'Delete event', event_path(@event),
method: :delete,
data: {
verify: {
message: 'NOTE: This will delete the event and all associated efforts and split times. This action cannot be undone. To verify, type the name of the event below and click Continue',
class: 'btn btn-sm btn-danger'
Do you have any ideas how to go about implementing something like this?


I tried to use "Rails" in the console as this video demoed. It didn't work with the error message "Rails is not defined". There seems to be a relevant Rails issue, , in which a Rails core member commented that: "When using rails-ujs with webpack window.Rails is indeed not defined."

There is a stackoverflow question on this topic:


I hate to have to say this. But it appears some moderation is necessary for the discussions.



Join the discussion
Create an account Log in

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

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

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

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2023 GoRails, LLC. All rights reserved.