# One-to-many through scaffolding?

**URL:** <https://www.ruby-forum.com/t/one-to-many-through-scaffolding/122506>\
**Category:** Rails\
**Created:** [December 8, 2007, 12:30pm UTC](https://www.ruby-forum.com/t/one-to-many-through-scaffolding/122506 "2007-12-08T12:30:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [December 8, 2007, 12:30pm UTC](https://www.ruby-forum.com/t/one-to-many-through-scaffolding/122506/1 "2007-12-08T12:30:50Z")

</div>

I’m working on my first one-to-many. Through scaffolds I have CRUD  
interfaces for the “feeds” and “items” tables. I have everything  
configured for a one-to-many O/R mapping, to my knowledge.

Is there a scaffold command I can run to create a CRUD interface with  
both “feeds” and “items” on the same interface?

All the code is hosted at the google repository, it can be browsed.  
Here  
are some specific links for some code (rather than posting it):

entry point:  
[http://strawr.googlecode.com/svn/trunk/](http://strawr.googlecode.com/svn/trunk/)

specific files:  
[http://strawr.googlecode.com/svn/trunk/app/controllers/feeds\_controller.rb](http://strawr.googlecode.com/svn/trunk/app/controllers/feeds_controller.rb)  
[http://strawr.googlecode.com/svn/trunk/app/controllers/items\_controller.rb](http://strawr.googlecode.com/svn/trunk/app/controllers/items_controller.rb)  
[http://strawr.googlecode.com/svn/trunk/app/models/feed.rb](http://strawr.googlecode.com/svn/trunk/app/models/feed.rb)  
[http://strawr.googlecode.com/svn/trunk/app/models/item.rb](http://strawr.googlecode.com/svn/trunk/app/models/item.rb)  
[http://strawr.googlecode.com/svn/trunk/db/migrate/001\_feeds.rb](http://strawr.googlecode.com/svn/trunk/db/migrate/001_feeds.rb)  
[http://strawr.googlecode.com/svn/trunk/db/migrate/003\_items.rb](http://strawr.googlecode.com/svn/trunk/db/migrate/003_items.rb)

thanks,

Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [December 8, 2007, 1:05pm UTC](https://www.ruby-forum.com/t/one-to-many-through-scaffolding/122506/2 "2007-12-08T13:05:55Z")

</div>

Do you mean the views will automatically show what the ActiveRecord  
model relationships are through the code generated?

On Dec 8, 2007 7:30 PM, Thufir [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [http://strawr.googlecode.com/svn/trunk/db/migrate/003\_items.rb](http://strawr.googlecode.com/svn/trunk/db/migrate/003_items.rb)

–  
Ramon T.

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [December 8, 2007, 1:21pm UTC](https://www.ruby-forum.com/t/one-to-many-through-scaffolding/122506/3 "2007-12-08T13:21:43Z")

</div>

On Sat, 08 Dec 2007 11:30:25 +0000, Thufir wrote:

> I’m working on my first one-to-many. Through scaffolds I have CRUD  
> interfaces for the “feeds” and “items” tables. I have everything  
> configured for a one-to-many O/R mapping, to my knowledge.
> 
> Is there a scaffold command I can run to create a CRUD interface with  
> both “feeds” and “items” on the same interface?

\<% for column in Feed.content\_columns %\>

**\<%= column.human\_name %\>:** \<%=h @feed.send(column.name) %\>

\<% end %\>

\<%= link\_to ‘Edit’, :action =\> ‘edit’, :id =\> @feed %\> |  
\<%= link\_to ‘Back’, :action =\> ‘list’ %\>

[http://strawr.googlecode.com/svn/trunk/app/views/feeds/show.rhtml](http://strawr.googlecode.com/svn/trunk/app/views/feeds/show.rhtml)

I think that I need to edit this file so that the list of feeds will  
include the items?

-Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [December 8, 2007, 2:26pm UTC](https://www.ruby-forum.com/t/one-to-many-through-scaffolding/122506/4 "2007-12-08T14:26:08Z")

</div>

On Sat, 08 Dec 2007 20:05:08 +0800, Ramon Miguel M. Tayag wrote:

> Do you mean the views will automatically show what the ActiveRecord  
> model relationships are through the code generated?

Maybe not automatically, but, yes, down the road, that’s what I want 🙂

Given:  
[http://strawr.googlecode.com/svn/trunk/app/views/feeds/list.rhtml](http://strawr.googlecode.com/svn/trunk/app/views/feeds/list.rhtml)

Can I at least tweak this (generated) file so that _all_ the fields are  
displayed when feeds is listed? I changing:

\<% for column in Feed.content\_columns %\>

to:

\<% for column in Feed.content %\>

but that didn’t have any visible effect ☹

Of course I’ll be hitting google, but…

If I can at least get those primary keys visible that will be progress!

thanks,

Thufir
