Newbie: parent-child view


#1

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


#2

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


#3

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