diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-09-07 12:52:27 +0100 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-09-07 12:52:27 +0100 |
commit | 2882543a8fcad4c38a9b45fa7e493ea04ee02d65 (patch) | |
tree | 7357dd048ec0315b7417f260b28d75867cb66619 /app | |
parent | c690679f5e55d908a0f91b0d9b3276ae3f748b2d (diff) | |
parent | 47f6141fd2ccf52c9149fe91893907db8894d65a (diff) |
Merge branch 'master' into wdtk
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/api_controller.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 718c31e6f..6c98ebeba 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -72,7 +72,12 @@ class ApiController < ApplicationController end def add_correspondence - request = InfoRequest.find(params[:id]) + request = InfoRequest.find_by_id(params[:id]) + if request.nil? + render :json => { "errors" => ["Could not find request #{params[:id]}"] }, :status => 404 + return + end + json = ActiveSupport::JSON.decode(params[:correspondence_json]) attachments = params[:attachments] @@ -83,11 +88,13 @@ class ApiController < ApplicationController errors = [] if !request.is_external? - raise ActiveRecord::RecordNotFound.new("Request #{params[:id]} cannot be updated using the API") + render :json => { "errors" => ["Request #{params[:id]} cannot be updated using the API"] }, :status => 500 + return end if request.public_body_id != @public_body.id - raise ActiveRecord::RecordNotFound.new("You do not own request #{params[:id]}") + render :json => { "errors" => ["You do not own request #{params[:id]}"] }, :status => 500 + return end if !["request", "response"].include?(direction) |