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.
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…
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