Ruby on rails 3 Michael Hartl指南第5章布局链接应在“/”号上有主页

Ruby on rails 3 Michael Hartl指南第5章布局链接应在“/”号上有主页,ruby-on-rails-3,Ruby On Rails 3,我有这个问题已经有一段时间了,我似乎无法将我的大脑包裹起来,因为我已经无数次地从头开始重建一切 无论如何,我在书中的一部分,我们希望主页链接从这一点去完美地工作的方式 基本上就是说我希望主页显示在根页面上 目前我的错误是 LayoutLinks的主页应位于“/” 失败/错误:response.should_选择器'title',:content=>Home 下面是一堆文字,上面写着页面应该是什么样子 现在我做了两件事,我首先创建了layout_links_spec.rb页面,将帮助页面添加到页面

我有这个问题已经有一段时间了,我似乎无法将我的大脑包裹起来,因为我已经无数次地从头开始重建一切

无论如何,我在书中的一部分,我们希望主页链接从这一点去完美地工作的方式 基本上就是说我希望主页显示在根页面上

目前我的错误是 LayoutLinks的主页应位于“/” 失败/错误:response.should_选择器'title',:content=>Home 下面是一堆文字,上面写着页面应该是什么样子

现在我做了两件事,我首先创建了layout_links_spec.rb页面,将帮助页面添加到页面_controller.rb,并将路由添加到config/routes.rb。下面是所有3个页面的代码

布局链接规格rb

require 'spec_helper'
describe "LayoutLinks" do
#  describe "GET /layout_links" do
#    it "works! (now write some real specs)" do
  # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
#      get layout_links_index_path
#      response.status.should be(200)

it "should have a Home page at '/'" do
get '/'
response.should have_selector('title', :content => "Home")
     end

it "should have a Contact page at '/contact'" do
get '/about'
response.should have_selector('title', :content => "About")
end

it "should have a Help page '/help'" do
get '/help'
response.should have_selector('title', :content => "Help")
  end
end
Pages\u controller.rb

def home
    @title = "Home"
  end

  def contact
        @title = "Contact"
  end

  def about
        @title = "About"
  end

  def help
        @title =  "Help"
  end 
end
config/routes.rb

SampleApp::Application.routes.draw do
match '/contact', :to => 'pages#contact'
match '/about',   :to => 'pages#about'
match '/help',    :to => 'pages#help'
root :to => 'pages#home'
end

有什么地方我做错了吗?

在路线的末尾添加端点。rb:
有一个块,用do打开,但您没有关闭它。仔细检查清单5.20。

它就在那里,我忘了添加它。您的意思是手动检查吗?你是说如果我真的喜欢a/home?我是说如果你使用浏览器访问localhost:3000/你会看到你的主页吗?不,我看到的只是默认主页欢迎你乘坐Ruby on Rails!:从public中删除index.html。顺便说一句,记住这一刻,当你开始为你的应用程序实现缓存时,你可能会遇到这个问题,它将在你的公共空间中创建index.html,你将试图了解你的主页到底发生了什么: