diff options
author | Denis Odorcic <denis.odorcic@jadedpixel.com> | 2011-10-10 01:42:12 -0400 |
---|---|---|
committer | Denis Odorcic <denis.odorcic@jadedpixel.com> | 2011-10-10 01:42:12 -0400 |
commit | a0a68ecbb22dacf5111198e72e3a803e7c965881 (patch) | |
tree | d96fc951fa27c3730e28ad28607cf5223f0e5c64 /actionpack/lib | |
parent | 3456ef11196406f4ae6908d89ec66d38dc716738 (diff) | |
download | rails-a0a68ecbb22dacf5111198e72e3a803e7c965881.tar.gz rails-a0a68ecbb22dacf5111198e72e3a803e7c965881.tar.bz2 rails-a0a68ecbb22dacf5111198e72e3a803e7c965881.zip |
JSON responder should return errors with :error root
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/metal/responder.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/metal/responder.rb b/actionpack/lib/action_controller/metal/responder.rb index 3794e277f6..c7827309dd 100644 --- a/actionpack/lib/action_controller/metal/responder.rb +++ b/actionpack/lib/action_controller/metal/responder.rb @@ -253,7 +253,7 @@ module ActionController #:nodoc: end def display_errors - controller.render format => resource.errors, :status => :unprocessable_entity + controller.render format => resource_errors, :status => :unprocessable_entity end # Check whether the resource has errors. @@ -286,5 +286,13 @@ module ActionController #:nodoc: def empty_json_resource "{}" end + + def resource_errors + respond_to?("#{format}_resource_errors") ? send("#{format}_resource_errors") : resource.errors + end + + def json_resource_errors + {:errors => resource.errors} + end end end |