On 5 September 2013 18:56, honey ruby <emailtohoneyr...@gmail.com> wrote:
> Thanks for the response Colin my last mail was deleted some how anyway
> thanks for your reply. So If I use association between the tables
>
> Table A                    Table B
> has_many B and      belongs_to A
>
> now I save a new record to A
> @table_a = TableA.save
> @table_b = ?
> what should be my next line so that id of that saved record will save in
> Table B

Really, you need to work through some good tutorials to get the basics
of rails.  Also read the Rails Guides, in particular the one on
Associations.

>
>
> And how should we approach this with out association if there is no rails
> only Ruby project

Don't know.

Colin

>
> help me on this
>
>
>
> On Thu, Sep 5, 2013 at 10:07 PM, Colin Law <clan...@googlemail.com> wrote:
>>
>> On 5 September 2013 17:12, honey ruby <emailtohoneyr...@gmail.com> wrote:
>> > Thanks for your quick responses. Does I get the same id if I use
>> > @whatever.reload.
>> > if that model is accessed often and there are multiple users working on
>> > same
>> > model and I want table A id to be saved as new record in table B
>> > Table A
>> > id     name       email
>> > 878   Sam         s...@mail.in.com
>> >
>> >
>> > as I save 878 record in Table A I want that 878 id to be saved as new
>> > record
>> > in table B
>> > Table B
>> > id       table_a_id
>> > 900     878
>>
>> As I suggested a little while ago when you first asked this question,
>> but did not reply to my response, you should consider doing this using
>> an association between the tables.  Something like table_b belongs_to
>> table_a, table_a has_many table_bs.  Then rails will do a lot of the
>> hard work for you.  Almost always in rails if you are manipulating id
>> values then you are doing it wrong.
>>
>> Colin
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ruby on Rails: Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to rubyonrails-talk+unsubscr...@googlegroups.com.
>> To post to this group, send email to rubyonrails-talk@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLs7jwBTiOh4dWLCrDEjDQOdfLceSYf9NY1qoTST8f%3DcqA%40mail.gmail.com.
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/CAOKUzCknCfEBTsiddykGqCb4K_goTpbG53bG%3DYuJFY75FHKx9A%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLt2wgmhDq7rP_%2Bh-V380yNaSLjG%2B1%3DHHV05cOvCH3Gs2A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to