Я создал _posts_controller.rb _:
class PostsController < ApplicationController
def index
end
end
Затем я создал файл index.html.erb в папке "app / views / posts":
<h1> Blog Post </h1>
Затем я добавил это к rout.rb :
Rails.application.routes.draw do
get 'home/index'
resources :posts
root 'home#index'
end
Я перезапустил сервер и получил эту ошибку при попытке доступа к странице индекса сообщений:
PostsController#index is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: [] NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.