Re: Re: Rails, insert into 3 tables from 1 controller

Colin Law
Mon, 04 Apr 2011 09:05:30 -0000

On 4 April 2011 09:46, HelloRails
<vitalizakharoff-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

Please don''t top post, it makes it difficult to follow the thread.
Insert your reply at appropriate points in previous message.  Thanks.

> And my email model has_many: tokens ?, right?

I don''t know, that is for you to say.
If an email has many tokens then token belongs to email and you need
an email_id in tokens table.  You do not appear to be setting that
when you create each token.

>
> Okei, i added belongs_to .. in my answer model.
>
> I mean doesn''t work.. questions is added successfully, but in
token
> models i dont have any tokens (I should have about 10).

Have you got any validations in Token that would prevent them being saved?
When you used ruby-debug to break in before the create does the code
get there ok?

Colin