undefined局部变量或方法`help_path'Hartl教程第8章

时间:2013-09-18 05:50:05

标签: ruby-on-rails ruby erb

我是铁杆的新手,并试图弄清楚我做了什么搞砸了。我做了rails并查看了我的主页并得到了错误

sample_app /应用/视图/布局/ _header.html.erb

undefined local variable or method `help_path'

<nav>
           <ul class="nav pull-right">
             <li><%= link_to "Home",    root_path %></li>
             <li><%= link_to "Help",    help_path %></li>
             <li><%= link_to "Sign in", '#' %></li>
           </ul>
         </nav>

help.html.erb

<% provide(:title, 'Help') %>
<h1>Help</h1>
<p>
  Get help on the Ruby on Rails Tutorial at the
  <a href="http://railstutorial.org/help">Rails Tutorial help page</a>.
  To get help on this sample app, see the
  <a href="http://railstutorial.org/book">Rails Tutorial book</a>.
</p>

_header.html.erb

<header class="navbar navbar-fixed-top navbar-inverse">
  <div class="navbar-inner">
    <div class="container">
      <%= link_to "sample app", root_path, id: "logo" %>
      <nav>
        <ul class="nav pull-right">
          <li><%= link_to "Home",    root_path %></li>
          <li><%= link_to "Help",    help_path %></li>
          <li><%= link_to "Sign in", '#' %></li>
        </ul>
      </nav>
    </div>
  </div>
</header>
抱歉这么新,有人认为他们可能知道问题是什么吗?

SampleApp::Application.routes.draw do
  resources :users
  resources :sessions, only: [:new, :create, :destroy]
  root  'static_pages#home'
  match '/signup',  to: 'users#new',            via: 'get'
  match '/signin',  to: 'sessions#new',         via: 'get'
  match '/signout', to: 'sessions#destroy',     via: 'delete'
  end

1 个答案:

答案 0 :(得分:0)

match '/help', to: 'static_pages#help' # in routes.rb