DEV Community

Discussion on: Setting up a new Rails 7 app with Vite, Inertia, and Svelte

Collapse
 
danielrlc profile image
Daniel Clarke • Edited

Thanks – great article! For anyone else new to Rails like me who gets stuck rendering their first Svelte view after following the article here, create/edit these files:

# config/routes.rb
Rails.application.routes.draw do
  root 'home#index'
end

# app/controllers/home_controller.rb
class HomeController < ApplicationController
  def index
    render inertia: 'home/index'
  end
end

<!-- app/frontend/pages/home/index.svelte -->
<h1>Home page</h1>
Enter fullscreen mode Exit fullscreen mode

(Feedback appreciated. I don't know if this is the standard "Rails way" or not.)

Collapse
 
buhrmi profile image
Stefan Buhrmester

The component file names are case-sensitive. Try render inertia: 'home'