# Newby (how to save information of two tables in a single dat

**URL:** <https://www.ruby-forum.com/t/newby-how-to-save-information-of-two-tables-in-a-single-dat/77145>\
**Category:** Rails\
**Created:** [November 24, 2006, 6:32pm UTC](https://www.ruby-forum.com/t/newby-how-to-save-information-of-two-tables-in-a-single-dat/77145 "2006-11-24T18:32:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike](https://www.ruby-forum.com/u/mike)\
**Post date:** [November 24, 2006, 6:32pm UTC](https://www.ruby-forum.com/t/newby-how-to-save-information-of-two-tables-in-a-single-dat/77145/1 "2006-11-24T18:32:25Z")

</div>

Hello,

```
 I'm very new on rails, I discovered it last week so, sorry if my

```

question are stupid, I am wainting for some books on rails, read some  
documentation but can’t solve this problems.

```
I imported gem for autenticate account (signup, login, logout) but

```

I want to extend it so the user fills some important information that  
will be stored in other table rather than users, this is the table  
company, when the user creates their account, a company would be  
created.

So I modify the rhtml of the view, include some fields of the  
company table, an in the controller user in signup method

```
 def signup
                @user = User.new

```

I inserted this line  
@company = Company.new

also in def create  
@company = Company.new(params[:firm])  
@user = User.new(params[:user])  
end

The form inserts the data for user, but not for company, any idea how  
to accomplish this?

Thank you

---

<div class="post-metadata">

**Author:** ![mike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike](https://www.ruby-forum.com/u/mike)\
**Post date:** [November 24, 2006, 6:50pm UTC](https://www.ruby-forum.com/t/newby-how-to-save-information-of-two-tables-in-a-single-dat/77145/2 "2006-11-24T18:50:28Z")

</div>

@company = Company.new(params[:company])

---

<div class="post-metadata">

**Author:** ![mike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike](https://www.ruby-forum.com/u/mike)\
**Post date:** [November 24, 2006, 6:50pm UTC](https://www.ruby-forum.com/t/newby-how-to-save-information-of-two-tables-in-a-single-dat/77145/3 "2006-11-24T18:50:28Z")

</div>

@company = Company.new(params[:company])

---

<div class="post-metadata">

**Author:** ![mike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike](https://www.ruby-forum.com/u/mike)\
**Post date:** [November 24, 2006, 7:22pm UTC](https://www.ruby-forum.com/t/newby-how-to-save-information-of-two-tables-in-a-single-dat/77145/4 "2006-11-24T19:22:30Z")

</div>

Sorry, the line is like you mentioned

@company = Company.new(params[:company])

and it just insert data in one table

Any other idea?

---

<div class="post-metadata">

**Author:** ![mike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike](https://www.ruby-forum.com/u/mike)\
**Post date:** [November 24, 2006, 8:24pm UTC](https://www.ruby-forum.com/t/newby-how-to-save-information-of-two-tables-in-a-single-dat/77145/5 "2006-11-24T20:24:36Z")

</div>

Mike wrote:

> Sorry, the line is like you mentioned
> 
> @company = Company.new(params[:company])
> 
> and it just insert data in one table

AnotherTable.create!(params[:another\_table])

?

–  
Phlip  
[Redirecting...](http://www.greencheese.us/ZeekLand) ← NOT a blog!!!
