【发布时间】:2013-12-31 01:35:24
【问题描述】:
每当我运行http://localhost:3000 时,我都会得到:
undefined local variable or method `faq_path' for #<#<Class:0x007fb238145c20>:0x007fb235054b98>
Extracted source (around line #12):
<body>
<%= link_to "Home", root_path %>
<%= link_to "About", about_path %>
<%= link_to "Faq", faq_path %>
<%= yield %>
</body>
</html>
我的路线文件
Document::Application.routes.draw do
root "pages#home"
get "about" => "pages#about"
get "faq" => "pages#faq"
我的页面控制器文件
class PagesController < ApplicationController
def home
end
def about
end
def faq
end
end
还有我的布局文件
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= link_to "Home", root_path %>
<%= link_to "About", about_path %>
<%= link_to "Faq", faq_path %>
<%= yield %>
</body>
</html>
这是我运行rake routes 时得到的结果
前缀动词 URI 模式控制器#Action
根 GET / pages#home
关于 GET /about(.:format) pages#about
常见问题 GET /faq(.:format) pages#faq
【问题讨论】:
-
你能告诉我们你的路线清单吗?只需在控制台输入
rake routes或更好的bundle exec rake routes
标签: ruby-on-rails