Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix to_xml for unprocessable_entity responses #250

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kzink
Copy link

@kzink kzink commented Sep 24, 2024

Rails 7+ has removed ActiveModel::Errors#to_xml which responders was relying on to emit :unprocessable_entity errors in xml format. You'll see something like this if it tries to render the error collection into a response:

undefined method `bytesize' for #<ActiveModel::Error attribute=name, type=blank, options={}>

I cobbled together a fix for this by pulling out the formatting method used in Rails 6 to restore the functionality. Unsure if this works in Rails <6 so it might be worth gating with a conditional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant