Forum: Ruby on Rails newbie: parent-child view

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A365e31aef8f4c7185216a3d84566922?d=identicon&s=25 Don Cameron (d1camero)
on 2006-03-13 06:57
I have a simple database: a list of manufacturers (parent) and the parts
(child) for the manufacturer.

From scaffold, I have a â??showâ? view  listing manufacturers.  I modified
this view to list the parts for the manufacturer.  I also have a link to
create a new part.  This causes the controller to display a new view to
create a new part for the manufacturer.

So creating the part is AOK,  I can even assign the manufacturerâ??s key
to the part (by passing the manufacturer ID though the session),
however, I want to return back to the manufacturer â??showâ? view.  I keep
on getting the error:


"Couldn't find Manufacturer without an ID"


Basically the manufacturer â??showâ? screen cannot find an ID to display.

I have tried:

-  passing the manufacturer ID through the session
-  setting a class level variable (if there is such a thing)



Any ideas?

thanks
Don
C5b6840775639751136a320d3cb47b12?d=identicon&s=25 Cheltis (Guest)
on 2006-03-13 07:57
why can't you simply pass it as parameter when redirecting to "show"
view?

don cameron wrote:
> Basically the manufacturer â??showâ? screen cannot find an ID to display.
>
> I have tried:
>
> -  passing the manufacturer ID through the session
> -  setting a class level variable (if there is such a thing)
>
>
>
> Any ideas?
>
> thanks
> Don
F59329dc91cba06600ff65c85fd3e93c?d=identicon&s=25 Anthony Green (acgreen)
on 2006-03-13 14:19
> So creating the part is AOK,  I can even assign the manufacturerâ??s key
> to the part (by passing the manufacturer ID though the session),
> however, I want to return back to the manufacturer â??showâ? view.  I keep
> on getting the error:
>
>
> "Couldn't find Manufacturer without an ID"

The link back to the manfacturer show view needs to include the id

ie

manufacture/show/id   # manufacture/show/1

use the link helper to write the manufacturer id in the session into the
link

not sure of the exact syntax but something akin to:

<%= link_to 'Show', :action => 'show', :id => @session.manufacturer_id
%>


_tony
This topic is locked and can not be replied to.