我正在尝试获取商店订单的订单但无法找到没有ID错误的订单
ActiveRecord :: RecordNotFound(无法找到没有ID的订单)
我试过
@order = Order.where("id = ? AND shop_id = ?", params[:id], @shop.id )
和另一个错误
所以,有人知道如何从关联对象中获取对象吗?
class OrdersController < ApplicationController
def sold
@shop = current_user.shop
@order = @shop.orders.find(params[:id])
end
end
路由
resources :orders, only: [:index, :update, :destroy] do
member do
get :sol
put :sent
end
collection do
match :sold
put :sent
match '/sold?status=paid ' => 'orders#sold', via: [:get,:put, :post], as: :shop_sold
end
end