Thanks for your reply David and Luca,
In respond to Luca:
When I’m calling DELETE /orders/1/items/1 I’m ending up in
ItemsController#destroy, right? There I find params[:order_id]
containing the id of the order and params[:id] the id of the item.
Now is this ItemController action allowed to invoke
Orderlines.find(:first, :conditions => { :order_id =>
params[:order_id], :item_id => params[:id] }).destroy? Or is this the
job of the destroy action of the OrderlinesController?
In respond to DHH:
An Orderline has an unique id, however in some views I do know the
Order I’m dealing with and the item I want to remove from this order,
but I don’t know the id of the Orderline which is connecting the Order
and the Item, that’s why I want to call
OrderlinesController#destroy(order_id, item_id), but as Luca pointed
out, the ItemsController may actually be a better place, what do you
think?
It’s now clear to me that this odd way of deleting Orderlines started
when I was iterating through Order#items where an Order has_many items
through orderlines. Then I don’t have the orderline id available
directly, however some requirements changed recently forcing me to
iterate through Order#orderlines, so now I do have the orderline_id
available to call OrderlinesController#destroy(id), however I’m still
curious about answers to the questions asked above.