This was the controller when I got the error.
order_controller.rb
def index
@item = Item.find(params[:id])
@user_item = UserItem.new
end
The conclusion was an error caused by not knowing that the ID name would change when nested. Searched by rails routes
item_orders GET /items/:item_id/orders(.:format) orders#index
I got the result, but what you should pay attention to is the /: item_id/part. It seems that the id name of the element that is a child element in the nest changes to [: (parent element name) _id]. In other words, the description of the correct answer is here.
order_controller.rb
def index
@item = Item.find(params[:item_id])
@user_item = UserItem.new
end
It was good to know that the ID name of the model that corresponds to the nested child element changes.
Recommended Posts