Closed ccastaneda13 closed 5 years ago
The validation query must be executed on master DB. Because of you can't validate when replication delay occurs.
example:
class User
validates :email, uniqueness: true
end
User.create!(email: "tsukasa.oishi@gmail.com")
# If replication delay is occuring, the following query will succeed!
User.create!(email: "tsukasa.oishi@gmail.com")
@tsukasaoishi thanks for the response! I see, will move the constraint to the database and remove the AR validation to avoid this query going to master.
Using fresh_connection 2.4.4 and when trying to create a record that has a uniqueness validation, the query checks for existence of the record against master and not replica. Is there any way to force the query to go to replica? Thanks
Running Rails 4.2.7 Ruby 2.3.4