Hi I'm newbie on Rail and interested in this Japanese article.

One of my answer about SPA

He is introducing SPA/PJAX without Vue or React

  • SPA on Rails way

  • not complex jQuery

I tried his code but cant feel as SPA.... because lack of my experience.

note:He mentioned this code is just example and don't check.

- layout
<div id="base">
   <%= link_to "Ajax!", remote: true, class: "getUsers" %>
    <div class="wrapper"></div>

- controller
class UsersController < ApplicationController
  layout false

  def index
    @users = User.all

- view
<div id="userCtrl">
    <% @users.each do |u| %>
        <li><%= u.name %></li>
     <% end %>

- css
#userCtrl {
  # CSS for userCtrl 

- js
$(function() {
  $(document).on("ajax:success", '#userCtrl .getUsers', function(q, data, xhr){
    $("#base .wrapper").html(data);

So my question is let me know how to use this code as SPA/PJAX with "Turbolinks".

Especially, there is no form so I think I am confused... Thanks for your help!!

0 Answers