All threads / jquery_ujs and rails-ujs problem ajax page

Ask A Question


You’re not receiving notifications from this thread.

jquery_ujs and rails-ujs problem ajax page

pikooli asked in Rails

hello everyone.

i am new in rails and ruby , i just started like 1 week ago .

i trying to do a chat between 2 people on rails, with jquery for the ajax part.

everything work, but i got this error that i don't undestand and it really bother me

image to the error (coun't include it with a image balise)

VM17:2082 Uncaught Error: If you load both jquery_ujs and rails-ujs, use rails-ujs only.

i undestand that i use jquery_ujs and rails-ujs in the same time , and rails want me to only use rails-ujs

my main page have this as code

<h1>welcome to the chat  </h1>
<div id='conv'>
    <div id='message'>
    <div id='sendmsg'>
    <%= form_tag "/", method: "post" do %>
        <input type='hidden' name='name' value='phil'/>
        <input id='tex' type="text" name="message" />
        <input id='sen' type="submit" value="send" />
    <% end %>

my javascript is like this

window.addEventListener('load', function () {
    function refreshMessage(){
            type: 'GET',
            url: '/chatBoard',
            success: function(data){
            error : function(){

this ajax send to the server a GET to '/chatBoard' and it will return all message in the database with this script.

<% @messages.each do |message| %>
<%= %> :
<%= message.message %>

<% end %>

i try to find a solution , but i am still stuck so i post it here , i would like to make this work but without this error ?
what should i do ? change my ajax request with a coffescript one ? haven't learn coffescript yet :/

thanks in advance.

Hello , i fixe it by commenting the application.js file and remove the rails/ujs :)

code still work , i think it work with the jquery_ujs thought

// require("@rails/ujs").start()
Join the discussion

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

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

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

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.