Dwight Watson's blog

Rails UJS outside the asset pipeline/with modules

This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.

With Rails 5.1 the team replaced the great jquery-ujs library with rails-ujs - the same feature set implemented without jQuery and rather using standalone Javascript. It's a welcome change, removing a dependency that most people are probably happy to get rid of by now.

However, if you try and load it up outside the Rails asset pipeline it's not as simple as //= require rails-ujs. When you use the module version of it you'll need to first import it, then start it. So, run yarn install rails-ujs to add the dependency and then boot it up in your app.

import Rails from "rails-ujs";


A blog about Laravel & Rails by Dwight Watson;
developer of Roomies.com, myRent.co.nz, High School Notes & StudentVIP.com.au.

Picture of Dwight Watson

Follow me on Twitter, or GitHub.