Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Manually transfering records with ActiveRecord (See related posts)

require 'rubygems'
require 'active_record'

class SourceTable < ActiveRecord::Base
  #set_table_name 'any_name'
  self.establish_connection(
    :adapter  => "mysql",
    :host     => "source_host",
    :username => "user",
    #:password => "mypass",
    :database => "source_database"
  )
end

class TargetTable < ActiveRecord::Base
  #set_table_name 'any_name'
  self.establish_connection(
    :adapter  => "mysql",
    :host     => "target_host",
    :username => "user",
    #:password => "mypass",
    :database => "target_database"
  )
end

records = SourceTable.find :all
records.each do |r|
  # transition logic goes here
  # t = TargetTable.new :field_one => 'xyz'
  # t.save
end


You need to create an account or log in to post comments to this site.