我运行了rake routes
并发现了很多不在我的routes.rb文件中的路由:
home_index GET /home(.:format) home#index
POST /home(.:format) home#create
new_home GET /home/new(.:format) home#new
edit_home GET /home/:id/edit(.:format) home#edit
home GET /home/:id(.:format) home#show
PUT /home/:id(.:format) home#update
DELETE /home/:id(.:format) home#destroy
我手动删除了在生成脚手架时创建的文件,但不知道如何完全清理该测试的混乱。
在我的routes.rb文件中,我有:
# define the root
root :to => "home#about"
# define all the possible routes from the home controller
resources :home do
get "about"
get "create_subscription"
end
答案 0 :(得分:0)
Rails为使用'resources'声明的任何内容创建了许多默认路由。你可以使用':only =>'解决这个问题。在您的路线文件中。请参阅http://guides.rubyonrails.org/routing.html#resources-on-the-web的第2.2和4.6节。