# Question on insert to multiple tables?

**URL:** <https://www.ruby-forum.com/t/question-on-insert-to-multiple-tables/185589>\
**Category:** Rails\
**Created:** [March 23, 2010, 5:20am UTC](https://www.ruby-forum.com/t/question-on-insert-to-multiple-tables/185589 "2010-03-23T05:20:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![longhorn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c5a1d2/32.png) [@longhorn](https://www.ruby-forum.com/u/longhorn)\
**Post date:** [March 23, 2010, 5:20am UTC](https://www.ruby-forum.com/t/question-on-insert-to-multiple-tables/185589/1 "2010-03-23T05:20:54Z")

</div>

Hello, every day i love more rails xD because after struggling a bit I  
could finally install the Active Scaffold plugin and it works great with  
this.

But now it is time to grow a little more on rails and am trying to make  
an ordering system and products. Which on my system I have these 3  
tables:

Product:  
=\> id\_product  
=\> name  
=\> amount  
=\> prices

Request:  
=\> id\_order  
=\> date\_order  
=\> recipient  
=\> address

Detalles\_pedido:  
=\> product\_id  
=\> order\_id  
=\> price\_unity  
=\> amount  
=\> total

So you see, the Active Scaffold allows me to work on each table CRUD  
apart, but now I need to create a form based on which prodcuts can  
submit all of my store and that the user choose the amount of each and  
then add address of the recipient and the date of order, fields that are  
in the order table. But while I have to insert in "ORDER\_DETAIL  
'respective ids and the amount and the respective total for the order.

And since I have been finding out something about a method @ task = @  
project.tasks.build (params [: task]) but does not help much, because  
maybe you need now is an array to insert in “ORDER\_DETAIL” and that it  
could be done in php but not much beyond that domain and, lo conosco no  
rails at all.

If rails is not an easier way to do this or if I can do all this with  
the Active Scaffold, as I see all these respects the relationship and  
insertions in different tables at once.

The truth’m a bit lost and I hope they can give me a hand that cat xD no  
idea where to start now!

---

<div class="post-metadata">

**Author:** ![longhorn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c5a1d2/32.png) [@longhorn](https://www.ruby-forum.com/u/longhorn)\
**Post date:** [March 23, 2010, 1:44pm UTC](https://www.ruby-forum.com/t/question-on-insert-to-multiple-tables/185589/2 "2010-03-23T13:44:20Z")

</div>

You are probably better of posting on the activescaffold group:

[http://groups.google.com/group/activescaffold](http://groups.google.com/group/activescaffold)

Unfortunately their documentation site is down at the moment but I’m  
pretty sure they describe how to do model associations in  
activescaffold.

[http://activescaffold.com/docs](http://activescaffold.com/docs)

To be honest if you are a beginner I wouldn’t recommend starting out on  
activescaffold - get the Agile Web D. with Rails book and learn  
the fundamentals first:

> **[Pragmatic Bookshelf: By Developers, For Developers](https://pragprog.com)**
>
> We improve the lives of professional developers. We create timely, practical books on classic and cutting-edge topics to help you learn and practice your craft, and accelerate your career. Come learn with us.

Cheers  
Luke
