3BJMTBOENVMUJQMF%#T
3BJMTTVQQPSUTUPFTUBCMJTIDPOOFDUJPOTUPEJ⒎FSFOU
EBUBCBTFTGPSFBDINPEFMT
class BlogBase < ActiveRecord::Base
self.abstract_class = true
establish_connection :production_blog
end
!
class Article < BlogBase; end
class Category < BlogBase; end
!
class Comment < ActiveRecord::Base
establish_connection :production_comment
end
$POpHVSBUJPO
*OJUJBMJ[FS
SwitchPoint.configure do |config|
config.define_switch_point :blog,
readonly: :"#{Rails.env}_blog_slave",
writable: :"#{Rails.env}_blog_master"
end
Slide 11
Slide 11 text
$POpHVSBUJPO
.PEFMT
class Article < ActiveRecord::Base
use_switch_point :blog
end
!
class Category < ActiveRecord::Base
use_switch_point :blog
end
!
class Comment < ActiveRecord::Base
use_switch_point :comment
end