Remove the old Rails view:
rm app/views/tasks/index.html.erb
TasksControllerEdit app/controllers/tasks_controller.rb:
class TasksController < ApplicationController
def index
tasks = Task.all
render status: :ok, json: { tasks: }
end
end
Note: { tasks: } is shorthand for { tasks: tasks } in Ruby 3.3.5+
bundle exec rails generate controller Home
This creates:
app/controllers/home_controller.rbapp/views/home/index.html.erbEdit app/controllers/home_controller.rb: