Ruby on Rails Thursday, March 31, 2011

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...@ruby-forum.com> 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@googlegroups.com.
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.

No comments:

Post a Comment