Ruby on rails Rails 3路由查找错误的控制器
首先,我在config/route.rb中有这个路由Ruby on rails Rails 3路由查找错误的控制器,ruby-on-rails,rails-routing,Ruby On Rails,Rails Routing,首先,我在config/route.rb中有这个路由 get 'inbox/index' => 'inbox#index' 然后我运行了rake routes,正确生成了路由: inbox_index GET /inbox/index(.:format) {:action=>"index", :controller=>"inbox"} 问题是当我试图从浏览器获取页面时(http://localhost:3000/inbox/index),出现一条错误消息: Argumen
get 'inbox/index' => 'inbox#index'
然后我运行了rake routes
,正确生成了路由:
inbox_index GET /inbox/index(.:format) {:action=>"index", :controller=>"inbox"}
问题是当我试图从浏览器获取页面时(http://localhost:3000/inbox/index),出现一条错误消息:
ArgumentError in InboxesController#index
wrong number of arguments (2 for 0)
应用程序跟踪中没有任何内容,并且在环境转储中生成了正确的控制器:
action_controller.instance: #<InboxController:0x7fbde79fb5a8 ...
我不知道如何找出这个问题,请给我一个提示。最后我发现了发生的事情 我定义了一个方法
InboxController#send
,Rails引入的元编程已经被破坏
错误消息与情况完全无关。InboxsController#索引确实是该路由试图到达的位置。=>'inbox#index'表示inbox资源的控制器,因此它应该多元化并向其中添加控制器,因此inbox控制器。
match "search" => 'search#search', :as => 'search', :via => [:get, :post]