Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cwsaylor/842371 to your computer and use it in GitHub Desktop.
Save cwsaylor/842371 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'active_record'
ActiveRecord::Base.configurations['db1'] = {
:adapter => "mysql",
:host => "",
:database => "",
:username => "",
:password => ""
}
ActiveRecord::Base.configurations["db2"] = {
:adapter => 'mysql',
:database => '',
:username => '',
:host => ''
}
class Wp_posts < ActiveRecord::Base
establish_connection "db1"
end
class Post < ActiveRecord::Base
establish_connection "db2"
end
old_posts = Wp_posts.all
old_posts.each do |old_post|
post = Post.create(:title => old_post.post_title, :body => old_post.post_content)
puts post.save
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment