ruby on rails索引操作默认情况下不加载

时间:2012-07-23 20:10:52

标签: ruby-on-rails controller indexing action

控制器:

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页错误...

1 个答案:

答案 0 :(得分:4)

您的路线应为:

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

将您的get "search/index"更改为:

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