【发布时间】:2021-11-10 15:51:45
【问题描述】:
Rail 版本详细信息
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x64-mingw32]
到目前为止我搜索了什么? - 以下都没有帮助我找出问题的根本原因
missing a template for this request format and variant
https://www.reddit.com/r/rails/comments/kkh4zg/why_am_i_getting_this_error/
https://www.ruby-forum.com/t/action-controller-is-missing-a-template-for-request-formats/255027
使用语法:rails new practise1 创建应用程序后,我在架构中添加了以下代码,
在 app/controller 中,创建了一个新的控制器 about_controller.rb
class AboutController < ApplicationController
def index
end
end
内部视图。创建了一个关于的新文件夹并添加了一个文件 index.html.erb
然后,最后在 config/routes.rb 文件中添加下面的代码,
Rails.application.routes.draw do
get "about", to: "about#index"
end
错误详情
【问题讨论】:
-
你的项目中
app/views/about/有html文件吗? -
内部视图。创建了一个关于的新文件夹并添加了一个文件 index.html.erb
-
你从
rake routes或rails routes得到什么? -
有一大堆路线,给你:i.stack.imgur.com/14Vv2.png
-
看起来不错。在您的
rails server中,它是否给出了系统找不到文件的特定路径? (可能是您的目录必须是“abouts”而不是“about”)。我还假设您正在“开发”模式下工作,而不是production?
标签: ruby-on-rails