【发布时间】:2016-11-19 09:57:00
【问题描述】:
我正在关注 M. Hartl 的 Ruby On Rails 教程的每一步,但一直停留在第 2 章(“Hello world”)。我在application_controller.rb改了代码:
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def hello
render html: "hello, world!"
end
end
还有routes.rb 到:
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'application#hello'
end
但我的http://localhost:3000 页面仍然是空白的。我正在使用带有 Rails 版本 5.0.0.1 和 Ruby 2.2.4p230 的 Postgres。
__
编辑1
我还用<h1>HELLO WORLD</h1> 创建了public/index.html,消息显示在页面上
__
编辑2
事实证明,您只需在对 routes.rb 进行任何更改后重新启动服务器
【问题讨论】:
-
我刚刚在我的本地机器上启动了
toyapp,并进行了您的确切更改并且它有效。 development.log 说什么?尝试渲染 localhost:3000 时检查/log/development.log
标签: ruby-on-rails ruby postgresql