From 9b2db870bcb99e840878807187fca5c2d6604cca Mon Sep 17 00:00:00 2001 From: Thomas Blazek Date: Thu, 22 Aug 2013 11:51:57 +0200 Subject: [PATCH 1/2] bugfix --- app/controllers/fotos_controller.rb | 8 ++++++-- app/models/foto.rb | 9 ++++----- app/views/fotos/_form_bulk.html.erb | 2 +- app/views/fotos/new.html.erb | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/controllers/fotos_controller.rb b/app/controllers/fotos_controller.rb index 3462c04..5a90a22 100644 --- a/app/controllers/fotos_controller.rb +++ b/app/controllers/fotos_controller.rb @@ -48,8 +48,12 @@ class FotosController < ApplicationController respond_to do |format| @foto.title = @foto.datei if @foto.save - format.html { redirect_to gallery_foto_path(@foto.gallery,@foto), notice: 'Foto was successfully created.' } - format.json { render json: gallery_foto_path(@foto.gallery,@foto), status: :created, location: [@gallery, @foto] } + format.html { + render :json => [@foto.to_jq_upload].to_json, + :content_type => 'text/html', + :layout => false + } + format.json { render json: {files: [@foto.to_jq_upload]}, status: :created, location: [@gallery, @foto] } else format.html { render action: "new" } format.json { render json: @foto.errors, status: :unprocessable_entity } diff --git a/app/models/foto.rb b/app/models/foto.rb index 868bf29..022d0fe 100644 --- a/app/models/foto.rb +++ b/app/models/foto.rb @@ -8,11 +8,10 @@ class Foto < ActiveRecord::Base "id" => read_attribute(:id), "title" => read_attribute(:title), "description" => read_attribute(:desc), - "name" => read_attribute(:file), - "size" => file.size, - "url" => file.url, - "thumbnail_url" => file.thumb.url, - "delete_url" => foto_path(:id => id), + "name" => read_attribute(:datei), + "size" => datei.size, + "url" => datei.url, + "thumbnail_url" => datei.thumb.url, "delete_type" => "DELETE" } end diff --git a/app/views/fotos/_form_bulk.html.erb b/app/views/fotos/_form_bulk.html.erb index 07999c2..209be7c 100644 --- a/app/views/fotos/_form_bulk.html.erb +++ b/app/views/fotos/_form_bulk.html.erb @@ -8,7 +8,7 @@ Add files... - <%= f.file_field :datei %> + <%= f.file_field :datei%> <%= f.input :gallery %>