Displaying 1 result from an estimated 1 matches for "readslav".
Did you mean:
readslave
2006 May 15
8
Databases... write master, multiple read-only slaves.. will this work?
...''m missing in the code below that''s going to bite me, such as
establish_connection creating a huge number of objects as time
progresses. Or is there a better way to flip the connection back and
forth?
The below does work though. Writes do go to :writemaster and reads go to
:readslave...
Comments?
class MyModel < ActiveRecord::Base
#.....
def before_save
ActiveRecord::Base.establish_connection(:writemaster)
end
def before_destroy
ActiveRecord::Base.establish_connection(:writemaster)
end
def after_save
ActiveRecord::Base.establish_connec...