Michael Hartl教程v.3.2第5.1章用户NoMethodError#new第4行

时间:2012-05-31 13:36:15

标签: ruby

我是新手,我正在通过Hartl慢慢地工作。刚刚开始Ch5。得到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章没有任何改变。所以我回去了,再次使用Ch.3,所有测试通过绿色和所有浏览器测试好我跳回到Ch.5。将Hartls新代码剪切并粘贴到views / layouts / application.html.erb中,保存文件,我得到相同的无方法错误。

1 个答案:

答案 0 :(得分:1)

看起来full_title帮助是在Chapter 4开头引入的。