honey ruby
2013-Aug-30 08:00 UTC
Insert row in one table and after save I want that Id in another table to be saved
Hi all There is a scenario with 2 tables. I will insert the one row in table 1 and after I save my row in table one I want that Id to be saved in another table immediately how to approach this scenario. kindly help me Regards, Honey -- 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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8dcf4c68-a521-4afe-922c-aeeb0a692d9d%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2013-Aug-30 08:13 UTC
Re: Insert row in one table and after save I want that Id in another table to be saved
On 30 August 2013 09:00, honey ruby <emailtohoneyruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all > > There is a scenario with 2 tables. > I will insert the one row in table 1 and after I save my row in table one I > want that Id to be saved in another table immediately how to approach this > scenario.Which bit don''t you know how to do? Where to put the code? How to determine the id of the row? How to find the record in the second table? How to change the value in the second table? How to save the value in the second table? Something else? But before that the more important question is whether you should have a belongs_to, has_many (or similar) association between the tables so that rails will do most of the work for you. 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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLs40oJi2b1B2de9qJ0MFxk9NRwRAduTaJMpi5SmjOTEtA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.