Sha256: c4d1e94cd1bb034eb4d4f2ab996c03c56bb8172b5b14da2926f59325d9233f14
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 KB
Contents
# -*- encoding : utf-8 -*- class RademadeAdmin::FileController < RademadeAdmin::AbstractController def upload param_key = params[:column].to_sym uploader.store!(params[param_key]) render :json => { :html => RademadeAdmin::Upload::PreviewService.new(uploader).preview_html, :file => uploader } rescue CarrierWave::UploadError => e render :json => { :error => e.to_s }, :status => :unprocessable_entity end def crop image = uploader.crop_image(params[:path], params[:crop]) uploader.store!(image) upload_preview_service = RademadeAdmin::Upload::PreviewService.new(uploader) render :json => { :html => upload_preview_service.preview_html, :file => uploader } rescue CarrierWave::UploadError => e render :json => { :error => e.to_s }, :status => :unprocessable_entity end private def uploader @uploader ||= RademadeAdmin::LoaderService.const_get(params[:uploader]).new(model, params[:column]) end def model model_class = RademadeAdmin::LoaderService.const_get(params[:model]) params[:saved].to_i.zero? ? model_class.new : model_class.find(params[:id]) end end
Version data entries
3 entries across 3 versions & 1 rubygems