Jquery-upload

This commit is contained in:
Thomas Blazek
2013-08-22 00:08:06 +02:00
parent f0349f9909
commit a2f3608d8f
7 changed files with 27 additions and 5 deletions

View File

@@ -80,3 +80,4 @@ gem "simple_calendar", "~> 0.1.9"
gem 'rmagick' gem 'rmagick'
gem 'bootstrap-addons-rails' gem 'bootstrap-addons-rails'
gem "jquery-fileupload-rails"

View File

@@ -82,6 +82,9 @@ GEM
hike (1.2.1) hike (1.2.1)
i18n (0.6.1) i18n (0.6.1)
journey (1.0.4) journey (1.0.4)
jquery-fileupload-rails (0.4.1)
actionpack (>= 3.1)
railties (>= 3.1)
jquery-rails (2.2.1) jquery-rails (2.2.1)
railties (>= 3.0, < 5.0) railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
@@ -194,6 +197,7 @@ DEPENDENCIES
git git
globalize3 (~> 0.3.0) globalize3 (~> 0.3.0)
haml haml
jquery-fileupload-rails
jquery-rails jquery-rails
paper_trail (>= 2.7.0) paper_trail (>= 2.7.0)
paperclip (~> 3.4.0) paperclip (~> 3.4.0)

View File

@@ -20,3 +20,4 @@
//= require bootstrap/datepicker //= require bootstrap/datepicker
//= require bootstrap/load-image.min //= require bootstrap/load-image.min
//= require bootstrap/image-gallery.min //= require bootstrap/image-gallery.min
//= require jquery-fileupload

View File

@@ -10,6 +10,7 @@
* *
*= require_self *= require_self
*= require_tree . *= require_tree .
*= require jquery.fileupload-ui
* require 'bootstrap' * require 'bootstrap'
*/ */

View File

@@ -25,7 +25,9 @@ class FotosController < ApplicationController
# GET /fotos/new.json # GET /fotos/new.json
def new def new
@foto = Foto.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| respond_to do |format|
format.html # new.html.erb format.html # new.html.erb
format.json { render json: @foto } format.json { render json: @foto }

View File

@@ -25,7 +25,7 @@ class GalleriesController < ApplicationController
# GET /galleries/new.json # GET /galleries/new.json
def new def new
@gallery = Gallery.new @gallery = Gallery.new
@foto = Foto.new
respond_to do |format| respond_to do |format|
format.html # new.html.erb format.html # new.html.erb
format.json { render json: @gallery } format.json { render json: @gallery }
@@ -41,7 +41,7 @@ class GalleriesController < ApplicationController
# POST /galleries.json # POST /galleries.json
def create def create
@gallery = Gallery.new(params[:gallery]) @gallery = Gallery.new(params[:gallery])
@foto = Foto.new
respond_to do |format| respond_to do |format|
if @gallery.save if @gallery.save
format.html { redirect_to @gallery, notice: 'Gallery was successfully created.' } format.html { redirect_to @gallery, notice: 'Gallery was successfully created.' }
@@ -57,7 +57,7 @@ class GalleriesController < ApplicationController
# PUT /galleries/1.json # PUT /galleries/1.json
def update def update
@gallery = Gallery.find(params[:id]) @gallery = Gallery.find(params[:id])
@foto = Foto.new
respond_to do |format| respond_to do |format|
if @gallery.update_attributes(params[:gallery]) if @gallery.update_attributes(params[:gallery])
format.html { redirect_to @gallery, notice: 'Gallery was successfully updated.' } format.html { redirect_to @gallery, notice: 'Gallery was successfully updated.' }

View File

@@ -2,5 +2,18 @@ class Foto < ActiveRecord::Base
attr_accessible :datei, :desc, :gallery_id, :title attr_accessible :datei, :desc, :gallery_id, :title
belongs_to :gallery belongs_to :gallery
mount_uploader :datei, FotoUploader 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 end