0

我是一个新手,我正在通过 Hartl 慢慢地工作。刚从第五章开始。到 5.1 并将新的样式代码添加到 application.html.erb 中,我得到“浏览器中的 Static_pages#home 中的 NoMethodError”。

这是终端读数:

Started GET "/static_pages/home" for 127.0.0.1 at 2012-05-31 14:02:03 +0100
Processing by StaticPagesController#home as HTML
  Rendered static_pages/home.html.erb within layouts/application (0.0ms)
Completed 500 Internal Server Error in 6ms

ActionView::Template::Error (undefined method `full_title' for #<#<Class:0x007f865b6a0160>:0x007f865b5faad0>):
    1: <!DOCTYPE html>
    2: <html>
    3: <head>
    4: <title><%= full_title(yield(:title)) %></title>
    5: <%= stylesheet_link_tag    "application", media: "all" %>
    6: <%= javascript_include_tag "application" %>
    7: <%= csrf_meta_tags %>
  app/views/layouts/application.html.erb:4:in `_app_views_layouts_application_html_erb__2520617125150382104_70107517560200'


  Rendered /Users/Lagaspi/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.6ms)
  Rendered /Users/Lagaspi/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.8ms)
  Rendered /Users/Lagaspi/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (9.1ms)

static_pages_controller

class StaticPagesController < ApplicationController

  def home
  end

  def help
  end

  def about
  end

  def contact
  end
end

成功完成第 3 章没有任何改变。所以我回去,再次工作第 3 章,所有测试都通过绿色并且所有浏览器测试都正常,我跳回第 5 章。将 Hartls 新代码剪切并粘贴到 views/layouts/application.html.erb 中,保存文件,我得到相同的无方法错误。

4

1 回答 1

1

看起来这个full_title助手是在第 4 章开始时介绍的。

于 2012-05-31T13:42:47.173 回答