2016-12-26 122 views
-11

我正在使用Rails應用程序。我遇到的問題是當我在我的關於和聯繫頁面之間循環時。我總是得到錯誤我正在使用Ruby on Rails應用程序

沒有路由匹配[GET] 「/頁/頁/關於」

沒有路由匹配[GET]「/網頁/網頁/聯繫「

我想改變路線我的導航欄部分標記href到"/about"但同樣的錯誤發生。它要求我使用命令耙路線,它顯示

$ rake routes 
    restaurants GET /restaurants(.:format)   restaurants#index 
       POST /restaurants(.:format)   restaurants#create 
new_restaurant GET /restaurants/new(.:format)  restaurants#new 
edit_restaurant GET /restaurants/:id/edit(.:format) restaurants#edit 
    restaurant GET /restaurants/:id(.:format)  restaurants#show 
       PUT /restaurants/:id(.:format)  restaurants#update 
       DELETE /restaurants/:id(.:format)  restaurants#destroy 
    pages_about GET /pages/about(.:format)   pages#about 
      root  /        restaurants#index 
    pages_contact GET /pages/contact(.:format)  pages#contact" 

可以有人請幫助我!

+0

請添加您的'a'或'link_to'標籤? – titan

+0

在哪裏你正在得到錯誤 –

回答

0

您的聯繫方式在/pages/about/pages/contact之下,但您訪問的網址是/pages/pages/about,該網址不存在。

您可以在耙路徑中看到系統中可能的URL。

,你需要在你的web應用程序的鏈接作爲

<%= link_to 'About', pages_about_path %> 

<%= link_to 'Contact', pages_contact_path %> 
+0

感謝您的迴應! <%= link_to'Contact',pages_contact_path%>標籤去哪裏?就像在我的application.html或navbar部分> –

+0

那裏現在的鏈接是。 NavBar會有一個很好的位置。 – coderhs

0
在你的路由

,你可以這樣做

#config/routes.rb 
ClientCruiser::Application.routes.draw do 
    .... 
    match "contact" => "pages#contact", :as => :contact, via: :all 
    match "about" => "pages#about", :as => :about, via: :all 
    .... 
    root :to => 'pages#index' 
end 

contact  /contact(.:format) pages#contact 
    about  /about(.:format) pages#about 
    root GET/    pages#index 

的方式輸出你會打電話將是

<%= link_to about_path, "About", class: '' %> 
<%= link_to contact_path, "Contact", class: '' %> 
相關問題