2
由於某些原因,這些URLS路由到相同的文件,當他們不應該,另一件事,當輸入一個無效的URL如localhost:3000/topics/inexjojvnsjg時,它只會停留在同一頁面上。本地主機:3000 /主題/索引和本地主機:3000 /主題/顯示兩個路由到相同的show.html文件
這裏是我的rails控制檯告訴我,當我嘗試訪問的URL localhost:3000/topics/index
Started GET "/topics/index" for ::1 at 2015-02-06 17:33:07 -0700
Processing by TopicsController#show as HTML
Parameters: {"id"=>"index"}
Rendered topics/show.html.erb within layouts/application (0.1ms)
User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."id" =$1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
Completed 200 OK in 98ms (Views: 96.5ms | ActiveRecord: 0.8ms)
這裏是我的路線文件....
Rails.application.routes.draw do
devise_for :users
get 'welcome/index'
get 'welcome/about'
# get "topics/index"
# get "topics/show"
# get "topics/new"
# get "topics/edit"
#for some reason, using resources:topics, index and show both route to show
resources :topics
root to: 'welcome#index'
post :incoming, to: 'incoming#create'
end
該死的!真棒。謝謝。 – 2015-02-07 01:21:33
@BartDangus,如果您認爲正確,請不要忘記接受答案! – 2015-02-07 19:11:18