直到最近我才开始遇到这个问题。我有一个完全自定义的RoR电子商务网站,我们刚刚完成了网站的重新设计。在这个过程的某个地方出现了一个路由问题,我似乎无法确定为什么它在没有问题之前就这样做了。
URI被视为:
/orders/295829fb4/items/379
Heroku日志正在吐出这个错误:
ActionController::RoutingError (No route matches "/orders/295829fb4/items/379"):
这是我的routes.rb订单
scope :constraints => { :protocol => (Rails.env.production? ? "https" : "http") } do
resources :orders, :only => [:show, :cart] do
member do
get :cart
end
resources :items, :only => [:create, :update, :destroy], :controller => 'order_items'
resource :address, :only => [:new, :edit, :create, :update]
resource :payment, :only => [:new, :create]
resource :discount, :only => [:create, :destroy]
resource :shipping_method, :only => [:update]
end
end
cart_order GET /orders/:id/cart(.:format) {:protocol=>"https", :controller=>"orders", :action=>"cart"}
order_items POST /orders/:order_id/items(.:format) {:protocol=>"https", :controller=>"order_items", :action=>"create"}
order_item GET /orders/:order_id/items/:id(.:format) {:protocol=>"https", :controller=>"order_items", :action=>"show"}
order_item PUT /orders/:order_id/items/:id(.:format) {:protocol=>"https", :controller=>"order_items", :action=>"update"}
order_item DELETE /orders/:order_id/items/:id(.:format) {:protocol=>"https", :controller=>"order_items", :action=>"destroy"}
order_address POST /orders/:order_id/address(.:format) {:protocol=>"https", :controller=>"addresses", :action=>"create"}
new_order_address GET /orders/:order_id/address/new(.:format) {:protocol=>"https", :controller=>"addresses", :action=>"new"}
edit_order_address GET /orders/:order_id/address/edit(.:format) {:protocol=>"https", :controller=>"addresses", :action=>"edit"}
order_address PUT /orders/:order_id/address(.:format) {:protocol=>"https", :controller=>"addresses", :action=>"update"}
order_payment POST /orders/:order_id/payment(.:format) {:protocol=>"https", :controller=>"payments", :action=>"create"}
new_order_payment GET /orders/:order_id/payment/new(.:format) {:protocol=>"https", :controller=>"payments", :action=>"new"}
order_discount POST /orders/:order_id/discount(.:format) {:protocol=>"https", :controller=>"discounts", :action=>"create"}
order_discount DELETE /orders/:order_id/discount(.:format) {:protocol=>"https", :controller=>"discounts", :action=>"destroy"}
order_shipping_method PUT /orders/:order_id/shipping_method(.:format) {:protocol=>"https", :controller=>"shipping_methods", :action=>"update"}
order GET /orders/:id(.:format) {:protocol=>"https", :controller=>"orders", :action=>"show"}
答案 0 :(得分:0)
看起来像是
resources :items, :only => [:create, :update, :destroy], :controller => 'order_items'
需要:显示该路线的方法。
resources :items, :only => [:show, :create, :update, :destroy], :controller => 'order_items'