Permalink
Browse files

output more errors to help with photo debugging.

  • Loading branch information...
1 parent 1d9837e commit ca2fbff2bc0d2322fd5d24736e87f05c5c6a36a2 @maxwell maxwell committed Jul 8, 2012
Showing with 15 additions and 11 deletions.
  1. +1 −1 app/assets/javascripts/app/forms/picture_form.js
  2. +14 −10 app/controllers/photos_controller.rb
@@ -29,7 +29,7 @@ app.forms.PictureBase = app.views.Base.extend({
if(resp.success) {
this.uploadSuccess(resp)
} else {
- alert("Upload failed! Check your URL.");
+ alert("Upload failed! Check your URL. Error:" + resp.error);
this.render()
}
}
@@ -9,18 +9,22 @@ class PhotosController < ApplicationController
respond_to :html, :json
def create
- unless params[:photo].present?
- respond_to do |format|
- format.any{ render :json =>{'success'=> false} }
+ begin
+ unless params[:photo].present?
+ respond_to do |format|
+ format.any{ render :json =>{'success'=> false} }
+ end
end
- end
- @photo = current_user.build_post(:photo, params[:photo])
- if @photo.save
- respond_to do |format|
- format.any{ render :json => {"success" => true, "data" => @photo.as_api_response(:backbone)} }
+ @photo = current_user.build_post(:photo, params[:photo])
+ if @photo.save
+ respond_to do |format|
+ format.any{ render :json => {"success" => true, "data" => @photo.as_api_response(:backbone)} }
+ end
+ else
+ render :json => {'error' => @photo.errors.full_messages}, :status => 422
end
- else
- render :json => {'error' => @photo.errors.full_messages}, :status => 422
+ rescue => e
+ render :json => {'error' => e.message}, :status => 422
end
end

0 comments on commit ca2fbff

Please sign in to comment.