jhpratt
jhpratt

Reputation: 7130

rails-ujs is required, but not loaded

application.js requires:

//= require rails-ujs
//= require turbolinks
//= require_tree .
//= stub ./sign

Clearly, rails-ujs is required in the same manner it is in the default config. I'm including this in the layout template with

<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload'%>`

In one of my views, I have the following code, which sets the method to delete.

<%= link_to 'delete',
  announcement_path(announcement),
  method: :delete,
  data: {
    confirm: 'Are you sure?'
  }
%>

This is properly rendered, with data-method='delete' being present on the link. Upon clicking that, it performs a GET request (visible in the logs).

Hopefully I'm missing something obvious. No errors appear in the console, and the rails-ujs file is not requested (per the network tab in the dev console).

Worth noting this is entirely local, not on a third party server.

Upvotes: 2

Views: 1219

Answers (1)

fool-dev
fool-dev

Reputation: 7777

You try to the following

On the Gemfile

 gem 'jquery-rails'

Then

bundle install

Then

//= require jquery
//= require jquery_ujs
#=> remove this line //= require rails-ujs

Make sure the restart your server after installing gem

jquery_ujs

Hope to help

Upvotes: 2

Related Questions