You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Moving a new Rails 8.0.1 app from development to production. When testing the authentication for the first time in production, Devise cannot write to the user table when signing in a user:
Information for cause: ActiveRecord::ReadOnlyError (Write query attempted while in readonly mode: UPDATE "users" SET "sign_in_count" = $1, "current_sign_in_at" = $2, "last_sign_in_at" = $3, "current_sign_in_ip" = $4, "last_sign_in_ip" = $5, "updated_at" = $6 WHERE "users"."id" = $7)
The problem occurs in the session controller on this line: sign_in(resource_name, resource)
To test, I can create and save a user record in the rails console. Until debugging this, I never knew of all the various options concerning primary and replica databases. I have only a primary Postgresql database (and others for cache, queue, and cable) and have added this to the application.rb file:
config.active_record.writing_role = :primary
config.active_record.reading_role = :primary
config.after_initialize do
ActiveRecord::Base.connected_to(role: :writing) do
ActiveRecord::Base.connection.execute("SET SESSION CHARACTERISTICS AS TRANSACTION READ WRITE")
ActiveRecord::Base.connection.execute("SET default_transaction_read_only = OFF")
end
end
And this is the updated database.yml section for the production database:
Still no joy though and the user record continues to be blocked from writing in Devise. What do I need to do in production to allow it to be written to? Thanks!
The text was updated successfully, but these errors were encountered:
Moving a new Rails 8.0.1 app from development to production. When testing the authentication for the first time in production, Devise cannot write to the user table when signing in a user:
The problem occurs in the session controller on this line:
sign_in(resource_name, resource)
To test, I can create and save a user record in the rails console. Until debugging this, I never knew of all the various options concerning primary and replica databases. I have only a primary Postgresql database (and others for cache, queue, and cable) and have added this to the application.rb file:
And this is the updated database.yml section for the production database:
Still no joy though and the user record continues to be blocked from writing in Devise. What do I need to do in production to allow it to be written to? Thanks!
The text was updated successfully, but these errors were encountered: