Created
November 23, 2011 13:59
-
-
Save larskanis/1388725 to your computer and use it in GitHub Desktop.
Test associations with per class database connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_record' | |
ActiveRecord::Base.configurations['my_connect'] = {:adapter=>'sqlite3', :database=>'fixture_database.sqlite3'} | |
class Car < ActiveRecord::Base | |
establish_connection 'my_connect' | |
has_many :tyres | |
end | |
class Tyre < ActiveRecord::Base | |
establish_connection 'my_connect' | |
belongs_to :car | |
end | |
car = Car.create :name=>'test-car' | |
tyre = car.tyres.create | |
p tyre.car |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment