Profile preference 404 error/admin profile not work
User f1r4s reports a 404 error when accessing their admin profile and preferences. They’ve tried upgrading, migrating the database, and disabling all plugins to no avail.
After reviewing logs, RGJ suggests disabling badges to resolve the issue, but f1r4s confirms this doesn’t work.
f1r4s shares log errors, including a NoMethodError related to badges. JammyDodger links a similar topic and suggests revoking or deleting custom badges. However, f1r4s is unsure how to do this.
JammyDodger provides a guide on editing or revoking badges, and suggests deleting a custom badge from the Badges section. However, f1r4s encounters a 500 error when trying to access the Badges section.
JammyDodger recommends using the Data Explorer to query the badges table. f1r4s runs the query and shares the results, which show most badges with a NULL image_upload_id except for three with a value of 17.
JammyDodger provides a console command to reset the image_upload_id to nil, which f1r4s uses to successfully fix the issue.
This seems to be the same issue as you posted before. I’ll link the other topic here in case there’s more info in there that can help people figure out what’s gone wrong:
I’m not sure I’m following this 100%. Is the issue that you can’t access the admin screen?
And you think this maybe because of some custom badges? Are other users with the custom badges affected? If so, could you revoke the custom badges, or delete them entirely?
I don’t think there’s an easy ‘reset’ you can do for the Badges, even from the rails console.
How far did you get with the Data Explorer query recommended in the other topic? Have you managed to track down which badge image is causing the issue?
After a bit of experimenting, I can replicate this glitch (or possibly something similar). I tried using the console to insert a “null” value in the image_upload_id in the Badge table, and it filled it with 0 instead. That locked up my test site in a very similar way to what you’ve described.
I ‘fixed’ it by changing all the image_upload_id to ‘1’. That allowed me back into my profile and the Badges section, but I now have to manually swop all the badges back to icon only, etc.
To check if yours is a similar problem can you access your data-explorer and create a new query and paste this in (and run):
Select name, image_upload_id
FROM badges b
Order By id desc
I have also figured out that it wants ‘nil’ not ‘null’ in the console to work properly.
This fixed my broken ones without needing to go through them all manually:
Badge.where('image_upload_id=0').find_each do |b|
b.image_upload_id = nil
b.save
end
Without knowing exactly what the issue with yours is, I can’t say for sure that will fix yours in the same way - though maybe a ‘change all to nil’ could work for you?