【发布时间】:2016-09-13 01:30:16
【问题描述】:
在 routes.rb 中执行以下操作后,我得到了“NameError”
Rails.application.routes.draw do
root 'static_pages#home'
get '/help', to: 'static_pages/help'
get '/about', to: 'static_pages/about'
get '/contact', to: 'static_pages/contact'
get '/sigunup', to: 'users#new'
end
有人可以帮帮我吗?谢谢。
Showing /home/bdme551/bdme21/app/views/layouts/_header.html.erb where line #7 raised:
undefined local variable or method `help_path' for #<#<Class:0x007f7474f3d208>:0x007f747555c508>
Extracted source (around line #7):
<ul class="nav navbar-nav navbar-right">
<li><%= link_to "Home", root_path %></li>
<li><%= link_to "Help", help_path %></li>
<li><%= link_to "Log in", '#' %></li>
</ul>
</nav>
StaticPagesController 有以下内容:
class StaticPagesController < ApplicationController
def home
end
def help
end
def about
end
def contact
end
end
【问题讨论】:
-
当出现该错误时,您想触发什么?你的路线很好。但是如果你试图触发
contact,你的控制器名称是拼写错误。
标签: mysql ruby-on-rails ubuntu passenger production