1

I've been having trouble getting JQuery to work on my rails app. It affected me weeks ago with a drop down menu and now I can not call the delete method via a link.

<% if current_user.admin? && !current_user?(user) %>
| <%= link_to "delete", user, data: { confirm: "You sure?" }, method: :delete %>

Here is my application.js file :

//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require_tree .

When I click the link delete, it sends me to the users profile when it's supposed to confirm delete, delete user, and then send me back to the user index. Also, when I switched "link_to" to "button_to" the delete method called correctly and the user was deleted and I was sent to user index and not users profile.

I've tried jquery not working in rails post, which I added script in the assets file and it did not work. Also tried various solutions from Rails 4 jQuery, javascript and coffee scripts not working and others that have not worked for me.

Let me know if anyone can help, thanks!

****Update ****

So, my application.js file actually had two other calls in it. Here is the full file ...

 //= require serviceworker-companion

if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('/serviceworker.js');
} 

//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require_tree .

Now, when I remove the if statement and the require service companion, or move them around in the file, I get a exception reentered error ... I am very confused.

Community
  • 1
  • 1
Jonathan Corrin
  • 1,219
  • 4
  • 17
  • 42
  • first of all check if jquery file is downloaded in browser. check if you have included javascript tag in the layout for the assets. Jquery may not be working because jquery file may be missing. – user3775217 Jan 05 '17 at 17:45
  • @user3775217 see new updates. Prior to the update. The javascript tag was in layout as ....`<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>` .... and was in browser when running locally as `` – Jonathan Corrin Jan 05 '17 at 18:22

0 Answers0