Payal Patel
2011-Mar-30 19:48 UTC
2 records getting inserted in two different tables using one database call
how would you execute 2 insert calls in just one database call in controller...eg Inserting a record in Users and Blogs tables using just one database/active record call. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Philip Hallstrom
2011-Mar-30 20:56 UTC
Re: 2 records getting inserted in two different tables using one database call
> how would you execute 2 insert calls in just one database call in > controller...eg Inserting a record in Users and Blogs tables using just > one database/active record call.Why would you want to do this? If you''re worried about atomicity, wrap it in a transaction... -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Matias Fierro
2011-Mar-31 12:37 UTC
Re: 2 records getting inserted in two different tables using one database call
Its not clear what you need or why you can''t just call two different inserts. But maybe a callback as after_create will help you. class User after_create :create_blog def create_blog Blog.create(:title => self.name) end end On Mar 30, 4:48 pm, Payal Patel <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> how would you execute 2 insert calls in just one database call in > controller...eg Inserting a record in Users and Blogs tables using just > one database/active record call. > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.