我这样做了:http://ruby.railstutorial.org/chapters/filling-in-the-layout#sec:user_signup.
但是当我尝试访问http://localhost:3000/pages/时,它返回"路由错误没有路由匹配"/pages"
这是我的routes.rb
Sample4App::Application.routes.draw do
get "users/new"
match '/signup', :to => 'users#new'
match '/contact', :to => 'pages#contact'
match '/about', :to => 'pages#about'
match '/help', :to => 'pages#help'
match '/', :to => 'pages#home'
end
This is my home.html.erb
<h1>Sample App</h1>
<p>
This is the home page for the
<a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
sample application.
</p>
<%= link_to "Sign up now!", signup_path, :class => "signup_button round" %>
我已经尽力了。但仍然。真的需要帮助。由于
您似乎错过了'/pages/'的实际路由。试着把它添加到你的routes.rb
match '/pages' => 'pages#home'
试试这个:
Sample4App::Application.routes.draw do
get "users/new"
match 'signup' => 'users#new'
match 'contact' => 'pages#contact'
match 'about' => 'pages#about'
match 'help' => 'pages#help'
match 'pages' => 'pages#home'
root :to => 'pages#index'
end
并确保在Pages
控制器中有index
动作
添加到root
root :to => 'pages#home'
你可以访问http://localhost:3000
或添加
match '/pages', :to => 'pages#home'
所以你可以访问http://localhost:3000/pages
try this
root :to => 'pages#index'
你删除了index.html。Erb from /public/ folder?删除它,然后再试一次-这应该可以解决问题:)