diff --git a/Gemfile b/Gemfile index 36a96f3..7f63ecb 100755 --- a/Gemfile +++ b/Gemfile @@ -80,3 +80,4 @@ gem "simple_calendar", "~> 0.1.9" gem 'rmagick' gem 'bootstrap-addons-rails' +gem "jquery-fileupload-rails" \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 9fba644..797788d 100755 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -82,6 +82,9 @@ GEM hike (1.2.1) i18n (0.6.1) journey (1.0.4) + jquery-fileupload-rails (0.4.1) + actionpack (>= 3.1) + railties (>= 3.1) jquery-rails (2.2.1) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) @@ -194,6 +197,7 @@ DEPENDENCIES git globalize3 (~> 0.3.0) haml + jquery-fileupload-rails jquery-rails paper_trail (>= 2.7.0) paperclip (~> 3.4.0) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index f880db0..97ab022 100755 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -20,3 +20,4 @@ //= require bootstrap/datepicker //= require bootstrap/load-image.min //= require bootstrap/image-gallery.min +//= require jquery-fileupload diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index b127f38..194f5be 100755 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -10,6 +10,7 @@ * *= require_self *= require_tree . + *= require jquery.fileupload-ui * require 'bootstrap' */ diff --git a/app/controllers/fotos_controller.rb b/app/controllers/fotos_controller.rb index 4090ae3..f5edc90 100644 --- a/app/controllers/fotos_controller.rb +++ b/app/controllers/fotos_controller.rb @@ -25,7 +25,9 @@ class FotosController < ApplicationController # GET /fotos/new.json def new @foto = Foto.new - + @gallery = Gallery.find_by_id(params[:gallery_id]) + @foto.gallery_id = @gallery.id + @foto.datei=@original_filename respond_to do |format| format.html # new.html.erb format.json { render json: @foto } diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 8ebf183..b51e1f8 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -25,7 +25,7 @@ class GalleriesController < ApplicationController # GET /galleries/new.json def new @gallery = Gallery.new - + @foto = Foto.new respond_to do |format| format.html # new.html.erb format.json { render json: @gallery } @@ -41,7 +41,7 @@ class GalleriesController < ApplicationController # POST /galleries.json def create @gallery = Gallery.new(params[:gallery]) - + @foto = Foto.new respond_to do |format| if @gallery.save format.html { redirect_to @gallery, notice: 'Gallery was successfully created.' } @@ -57,7 +57,7 @@ class GalleriesController < ApplicationController # PUT /galleries/1.json def update @gallery = Gallery.find(params[:id]) - + @foto = Foto.new respond_to do |format| if @gallery.update_attributes(params[:gallery]) format.html { redirect_to @gallery, notice: 'Gallery was successfully updated.' } diff --git a/app/models/foto.rb b/app/models/foto.rb index f548189..868bf29 100644 --- a/app/models/foto.rb +++ b/app/models/foto.rb @@ -2,5 +2,18 @@ class Foto < ActiveRecord::Base attr_accessible :datei, :desc, :gallery_id, :title belongs_to :gallery mount_uploader :datei, FotoUploader - + resourcify + def to_jq_upload + { + "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), + "delete_type" => "DELETE" + } + end end