From 713d30bdb6abd3c328d1835cb0a65804539b8db1 Mon Sep 17 00:00:00 2001 From: Keith Pitt Date: Fri, 4 Feb 2011 15:44:42 +0800 Subject: [PATCH] Hacked the admin images controller to work --- app/controllers/admin/images_controller.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/images_controller.rb b/app/controllers/admin/images_controller.rb index a3123426..54eb8cb2 100644 --- a/app/controllers/admin/images_controller.rb +++ b/app/controllers/admin/images_controller.rb @@ -17,13 +17,16 @@ module Admin end def create - params[:asset] = { :name => params[:name], :source => params[:file] } if params[:file] + params[:asset] = { :name => params[:name], :source => params[:file], :collection => begin_of_association_chain } if params[:file] - create! do |success, failure| - success.json do - render :json => image_to_json(@asset) - end - failure.json { render :json => { :status => 'error' } } + a = Asset.new(params[:asset]) + + begin + a.save! + render :json => image_to_json(a) + rescue Exception => e + # Rails.logger.info e.backtrace.join("\n") + render :json => { :status => 'error' } end end