Forum: Ruby on Rails Nested Resources and Routes

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
8d295740bdc6fecc406cff2e8b895f48?d=identicon&s=25 Sahil Dave (Guest)
on 2009-02-25 09:27
(Received via mailing list)

i have some nested resources like, a deal has_many :orders and has_one
i am using nested routing for these. so the urls are like:


and others for the whole CRUD

although everything is working perfectly, the updates for a nested
are stuck. e.g. the edit page for an order comes up, buts submitting it
gives me an error:

Couldn't find Order without an ID
app/controllers/duties_controller.rb:92:in `get_order'

i have created a before_filter :get_deal

def get_deal
  @deal = Deal.find(params[:deal_id])

do i need to change something in my edit/update actions?? right now they
default ones generated after scaffolding.


57777e93348c9b8d1e8c7511da1287ba?d=identicon&s=25 Richard Aday (Guest)
on 2009-02-25 19:24
(Received via mailing list)
You need to change the way you reference orders so that you scope an
within a deal.

Give this a shot and let me know if it works:


Index action:
@order = @deal.orders.find(:all)

Show action:
@order = @deal.orders.find(params[:id])

New action:
@order =

Edit action:
@order = @deal.orders.find(params[:id])

Create action:
@order =[:order])

Update action:
@order = @deal.orders.find(params[:id])

Delete action:
@order = @deal.orders.find(params[:id])

On Wed, Feb 25, 2009 at 3:26 AM, Sahil Dave <>

> and others for the whole CRUD
> def get_deal
> >

-Richard Aday
8d295740bdc6fecc406cff2e8b895f48?d=identicon&s=25 Sahil Dave (Guest)
on 2009-02-26 08:47
(Received via mailing list)
On Feb 25, 11:23 pm, Richard Aday <> wrote:
> You need to change the way you reference orders so that you scope an order
> within a deal.

thank for the suggestion Richard.. but i managed to do it by adding
an :except clause to the before filter to work on only new and edit
This topic is locked and can not be replied to.