• 22

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /var/www/html/cnasolution/site/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/site/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/site/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

rails 6 ajax “remote: true” does nothing

I had a working application when I went to bed, and when I booted it back up this morning, the AJAX no longer seemed to work, and remote:true does not seem to do anything. I have spent most of the day trying answers to related questions to no avail.

In categories/index.html.erb (set as root), I link to the SHOW request for each category, and the container for the result, referenced in categories/show.js.erb

    <% @categories.each do |category| %>
  • <%= link_to category.name, category, remote: true %>
  • <% end %>
This should load the contents of category/_show.html.erb

The show.js.erb:

$('#somevehicles').html("<%= j render 'categories/show', category: @category %>") 

The _show.html.erb:

<% @category.vehicles.each do |p| %>     <%= p.name %> <% end %> 

in categories_controller.rb

class CategoriesController < ApplicationController   before_action :set_category, only: [:show, :edit, :update, :destroy] . . .   def show    end . . . 

When I run the rails server in dev i recieve no errors. Instead, when I click on the rendered <%= link_to category.name, category, remote: true %>, it takes me to show.html.erb(no underscore), which is where it would go if there were no remote:true at all. Before, even without complete AJAX or a corresponding .js.erb, adding remote:true to the tag made it so the link went nowhere, so I'm stuck.

Download script demo [LINK] [Origin]
Download script demo [LINK 2] [Onedrive] Download script demo [LINK 2] [Google drive]


I switched to every git commit, starting from my first confirmed working version, ending back at the most recent version that I opened this morning. All I did was git checkout, ran yarn install --check-files if required after running rails s, and testing to see if the AJAX worked.

After reverting back to the most recent version and running the rails server, everthing worked. So, the fix was to turn it off and back on again. That or yarn install --check-files.

see demo
  • 38
Reply Report