2012-07-23 56 views
0

的控制器加載:Ruby on Rails的索引操作不是默認

class SearchController < ApplicationController 

    def index 

    end 

end 

的routes.rb

get "search/index" 

rake routes

search_index GET /search/index(.:format)  search#index 

當我嘗試去http://localhost:3000/search我得到404頁錯誤...

回答

4

你的路線應該是:

search_index GET /search(.:format)    search#index 

更改get "search/index"到:

resources :search, :only => [:index] 
+0

你的救星!非常感謝! – fxuser 2012-07-23 20:23:12