我的路线返回一个空白视图(查看源代码时没有html) [英] My route returns a blank view (no html when I do view source)
问题描述
我是Ruby on Rails的 全新 ,并且我一直在尝试建立简单的默认路由并正常工作。当我尝试运行我的应用程序时,我得到的结果是空白的(如果我执行视图源,那里什么也没有)。
I am brand new to Ruby on Rails and I have been trying to get a simple default route set up and working. When I try to run my application I get a blank result (if I do a view source, there is nothing there).
以下是相关文件(不确定是否我缺少一些有用的东西。)
Here are the relevant files (not sure if I am missing something that would be useful).
Blog::Application.routes.draw do
root :to => "home#index"
end
app / views / home / index.html.erb
app/views/home/index.html.erb
<h1>Home#index</h1>
<p>Find me in app/views/home/index.html.erb</p>
app / controllers / home_controller.rb
app/controllers/home_controller.rb
class HomeController < ApplicationController
def index
end
end
app / views / layouts / application.html.erb
app/views/layouts/application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>Benji</title>
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
</head>
<body>
<%= yield %>
</body>
</html>
当我尝试运行我的应用程序时,我进入 http:// localhost:3000 而没有任何显示。如果执行视图源,则为空。
When I try to run my application, I go to http://localhost:3000 and nothing shows up. If I do a view source, it is empty.
如果使用耙路
,结果如下:
JESSE-GAVINs-MacBook-Pro-17:benji jesse$ rake routes
(in /Users/jesse/Dev/benji)
root /(.:format) {:action=>"index", :controller=>"home"}
JESSE-GAVINs-MacBook-Pro-17:benji jesse$
在我的development.log文件中,我看到以下内容:
In my development.log file I see this:
Started GET "/" for 127.0.0.1 at Tue Sep 07 10:44:10 -0500 2010
Processing by HomeController#index as HTML
Rendered home/index.html.erb within layouts/application (2.8ms)
Completed 200 OK in 15ms (Views: 14.7ms | ActiveRecord: 0.0ms)
可能是什么问题?我该如何解决呢?
What could be the issue? How do I go about solving this?
推荐答案
已解决(有点...)
当我在其他端口上启动Rails服务器时,它工作得很好。
Solved (sort of...)
It works just fine when I started the rails server on a different port.
据我了解,我不需要重新启动服务器即可检测到代码中的更改。
It was my understanding that I didn't need to restart the server in order for it to detect changes in the code.
很抱歉浪费时间,我只是不知道我需要吠叫哪棵树。一路上我学到了一些东西。
Sorry about the waste of time, I just didn't know which tree I needed to bark up. I learned some things along the way.
这篇关于我的路线返回一个空白视图(查看源代码时没有html)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!