Scaffolds, Multiple Tables, and Key Fields

Is there a simple way to edit two tables with a has_many/belongs_to relationship? I have a very typical parent table (Departments) with an id, name, description, etc. And I have a child Resources table with an id, department_id, title, description, and other fields.

I want to allow a user to edit the child table but I see that the standard behavior for scaffolds is to suppress displaying key fields (primary and foreign) is there a way to override this?

Basically when I'm editing the child record I really need to display the Department.title. I know I can do this by hand, but I'd like the scaffolding to help me if possible! is it?

Thanks,

Gary H.

Check out the 3-part screencast on complex forms at railscasts.com starting with #73

This will walk you through setting up editing two forms at once if you want something more complex.

Basically when I'm editing the child record I really need to display the Department.title. I know I can do this by hand, but I'd like the scaffolding to help me if possible! is it?

I don't know of a way for Scaffold to do it, possibly ActiveScaffold would. http://activescaffold.com/

or just In your Resources (that's the child right?) view, use this in your _form <%= collection_select :resource, :department_id, Department.find(:all), :id, :name %>

Read more about collection_select here:

it puts in department_id of a resource from what was collected from all department listings and give you a select field with id of department as a value and name of department as text.

and in your list use <%= resource.department.name %> inside the for statement, and in show <%= @resource.department.name %> anywhere.