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
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)
You need to create an account or log in to post comments to this site.
Related Posts
» Simple accessor method for A... in ruby rails activerecord
» Ruby: Apple Aperture API in ruby apple activerecord sqlite api aperture module
» acts_as_state_machine model in ruby rails activerecord state acts_as_state_machine
» ActiveRecord reconnect to da... in ruby rails activerecord console ar merb orm reconnect
» Typo under lighttpd in lighttpd ruby rails typo ruby-fcgi
» password hash script in ruby password
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails