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

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

View File

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

View File

@@ -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 }

View File

@@ -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.' }

View File

@@ -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