-
Notifications
You must be signed in to change notification settings - Fork 61
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
Handle validation errors #49
Comments
@apotonick +1. Seems like it doesn't look for a Representer when there is a validation error. That's right? |
That would be an |
FYI, I've solved this with redefined
def render(*args)
options = args.dup.extract_options!
if options[:json] && options[:json].is_a?(Hash) &&
options[:json][:errors].is_a?(ActiveModel::Errors)
options[:json][:errors] = options[:json][:errors].full_messages
super options
else
super
end
end |
If you want to return a generic errors document, there should be a generic Introducing that, you wouldn't have to override |
I guess it won't work with current implementation of roar-rails. Rails won't render I think that we can try to decorate resource earlier to take control over |
It seems for now roar-rails' responder doesn't handle validation errors transparently (correct me if I'm wrong) like rails' builtin responder does, see ActionController::Responder docs. Today I write this:
but I'd like this to automatically happen (depending if resource
has_errors?
..) so we can write this:Could you :
If it sounds good I can work on that and submit a pull request in a few weeks.
The text was updated successfully, but these errors were encountered: