Rails入门项目在错误的路径中渲染模板

时间:2018-12-20 21:45:31

标签: ruby-on-rails ruby

我刚刚设置了Rails开发环境,并使用rails new命令创建了一个新的Rails项目。当我运行bundle exec rails s时,一切正常启动,除了渲染的模板为/home/ubuntu/.rvm/gems/ruby-2.5.1/gems/railties-5.2.2/lib/rails/templates/rails/welcome/index.html.erb而不是我的实际项目/home/ubuntu/github/project/app/views/layouts/application.html.erb

对我的项目进行更改也不会反映在服务器上。这肯定是我在某个地方犯的一个愚蠢的错误,但我似乎无法弄清。

示例请求日志:

Started GET "/" for 127.0.0.1 at 2018-12-20 17:05:52 +0000
Processing by Rails::WelcomeController#index as HTML
  Rendering /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/railties- 
5.2.2/lib/rails/templates/rails/welcome/index.html.erb
  Rendered /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/railties- 
5.2.2/lib/rails/templates/rails/welcome/index.html.erb (1.6ms)
Completed 200 OK in 5ms (Views: 4.3ms | ActiveRecord: 0.0ms)

1 个答案:

答案 0 :(得分:3)

您需要创建路由和该路由的控制器。您正在查看Rails在安装和运行时呈现的默认页面。