Code bug
ActiveRecord::RecordInvalid
Validation failed: Care extender brands must have at least one brand, Roles must include at least one role
In one line
db/seeds.rb creates the bootstrap admin CareExtender without brands or roles, which the model now rejects, so the seed fails whenever that admin record is missing.
Checked against the code
What happened
- `db/seeds.rb` runs `CareExtender.create!` for the admin user (pushparaj.dhond@mindoula.com in production) only if that record isn't found.
- The call passes no brands and no pending_roles.
- `CareExtender` validates at least one brand (unless skip_mmr_validations) and, on create, at least one role, so create! raises RecordInvalid.
- Only 2 events in 7 days, both from the rake db:seed run during deploys. The seed is normally a no-op because the admin already exists, so it only fails when that record is missing.
What to do next
- Query
Shows whether the production admin exists; if not, that explains why create! ran. Check db/schema.rb first, since the deleted_at column may not exist.
SELECT id, email, active, deleted_at FROM care_extenders WHERE email IN ('pushparaj.dhond@mindoula.com','admin@mindoula.com'); - Check Decide how the seed should supply a brand and a role for the bootstrap admin: for example an existing Brand record plus pending_roles, or skip_mmr_validations. Then edit db/seeds.rb. Also confirm whether the production admin was deliberately removed or renamed.
Queries are shown, never run. Check them before using them on production.
Ask a follow-up
Continues the same session, so it still remembers the error and the code it read.
Analysed 1 h ago · claude-sonnet-5-5 · $0.05