1
因此,出于某种原因,我在尝试发布到该网址时收到“无路线匹配”/ accounting/payment_objects/57/comments“”。如何解决这个路由错误?
正如你从耙路径中看到的那样,这个URL是路由的。
现在这里有一些奇怪的事情,GET请求工作,但POST请求不。
另外我可以使用_path帮助器方法来生成路由。
accounting_payment_object_comments GET /accounting/payment_objects/:payment_object_id/comments(.:format) {:action=>"index", :controller=>"accounting/comments"}
POST /accounting/payment_objects/:payment_object_id/comments(.:format) {:action=>"create", :controller=>"accounting/comments"}
但是,当我张贴到它,登录返回此:
Started POST "/accounting/payment_objects/57/comments" for 127.0.0.1 at Fri Jul 22 14:53:58 +0800 2011
ActionController::RoutingError (No route matches "/accounting/payment_objects/57/comments"):
Rendered /Users/pma/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.7ms)
我已经证实了这无关我的控制器/行动。
但是,我的routes.rb中有一段代码与此问题有关。
namespace 'accounting' do
resource :requisitions, :only => [:show] do
collection do
get 'filter'
end
end
resource :purchase_orders, :only => [:show]
resource :accounts_payable, :only => [:show]
resource :payment_requests, :only => [:show, :update]
resource :general_ledger, :only => [:show]
resource :permissions, :only => [:update]
resources :payment_objects do
collection do
get 'filter'
post 'permissions'
end
member do
match 'approve'
match 'decline'
end
resources :items do
member do
get 'receive' => 'items#received_form'
post 'receive' => 'items#process_received_form'
end
resources :receiving_records, :only => [:create, :new]
end
resources :files
resources :comments, :except => [:show, :new]
end
end
我在会计名称空间中实际上没有注释控制器,但我可以通过使用相同的资源路由来检索索引。 – fivetwentysix
你可以发布日志与请求索引操作? – Bohdan