From 09fc68eef0d54e54a463ed7c0e28c99f0e2b575a Mon Sep 17 00:00:00 2001 From: Thomas Blazek Date: Thu, 22 Aug 2013 11:16:32 +0200 Subject: [PATCH] uploader --- app/controllers/fotos_controller.rb | 8 +++++--- app/views/fotos/new.html.erb | 4 ++-- config/routes.rb | 3 +-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/controllers/fotos_controller.rb b/app/controllers/fotos_controller.rb index f5edc90..3462c04 100644 --- a/app/controllers/fotos_controller.rb +++ b/app/controllers/fotos_controller.rb @@ -27,7 +27,6 @@ class FotosController < ApplicationController @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 } @@ -44,10 +43,13 @@ class FotosController < ApplicationController def create @foto = Foto.new(params[:foto]) + @foto.gallery_id = (params[:gallery_id]) + @gallery = @foto.gallery 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: @foto } + format.json { render json: gallery_foto_path(@foto.gallery,@foto), status: :created, location: [@gallery, @foto] } else format.html { render action: "new" } format.json { render json: @foto.errors, status: :unprocessable_entity } @@ -78,7 +80,7 @@ class FotosController < ApplicationController @foto.destroy respond_to do |format| - format.html { redirect_to fotos_url } + format.html { redirect_to galleries_url } format.json { head :no_content } end end diff --git a/app/views/fotos/new.html.erb b/app/views/fotos/new.html.erb index a76f8c8..50e5976 100644 --- a/app/views/fotos/new.html.erb +++ b/app/views/fotos/new.html.erb @@ -1,5 +1,5 @@

New foto

-<%= render 'form' %> +<%= render 'form_bulk' %> -<%= link_to 'Back', fotos_path %> +<%= link_to 'Back', gallery_fotos_path(params[:gallery_id]) %> diff --git a/config/routes.rb b/config/routes.rb index bd638f7..22924ab 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -36,9 +36,8 @@ get 'verwalten/studien', :controller=>:studien, :action=>:verwalten, :as=>'studien_verwalten' resources :fetzneditions - resources :fotos, :except=>[:new, :show] resources :galleries do - resources :fotos, :only=>[:new,:show] + resources :fotos end resources :memberships, :except=>[:new, :show, :edit] resources :gremien