I followed some tutorials on new release Rails 6.0.0.beta3 and trying to 
implement connection switching multiple database this way:

*database.yml*

default: &default
adapter: mysql2
encoding: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password: root
socket: /var/run/mysqld/mysqld.sock

development:
  main:
    <<: *default
    database: r6_multidb_development

  main_replica:
    <<: *default
    database: r6_multidb_development_copy
    replica: true


*Article Model*

*class Article < ApplicationRecord connect_to database: { writing: :main, 
reading: :main_replica } end*

Both the databases r6_multidb_development and r6_multidb_development_copy 
have different records, i was expecting when record is created records 
should inserted on r6_multidb_development Database and when retrieving 
record it should from r6_multidb_development_copy database. But in both 
cases when record is inserted and retrieved it is happening from main 
configuration that is r6_multidb_development database.

I believe write to the database should happen from r6_multidb_development 
and read should happen from r6_multidb_development_copy. I would appreciate 
if anybody figure out this issue.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to