0

我是 Rails 新手,想弄清楚我做了什么把事情搞砸了。我做了 rails s 并查看了我的主页并得到了错误

sample_app/app/views/layouts/_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>

帮助.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
4

1 回答 1

0
match '/help', to: 'static_pages#help' # in routes.rb
于 2013-09-18T06:06:08.653 回答