diff --git a/app/controllers/fotos_controller.rb b/app/controllers/fotos_controller.rb index 591bf1f..4090ae3 100644 --- a/app/controllers/fotos_controller.rb +++ b/app/controllers/fotos_controller.rb @@ -44,8 +44,8 @@ class FotosController < ApplicationController respond_to do |format| if @foto.save - format.html { redirect_to @foto, notice: 'Foto was successfully created.' } - format.json { render json: @foto, status: :created, location: @foto } + 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 } else format.html { render action: "new" } format.json { render json: @foto.errors, status: :unprocessable_entity } @@ -60,7 +60,7 @@ class FotosController < ApplicationController respond_to do |format| if @foto.update_attributes(params[:foto]) - format.html { redirect_to @foto, notice: 'Foto was successfully updated.' } + format.html { redirect_to gallery_foto_path(@foto.gallery,@foto), notice: 'Foto was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } diff --git a/app/models/foto.rb b/app/models/foto.rb index 08a5d59..f548189 100644 --- a/app/models/foto.rb +++ b/app/models/foto.rb @@ -1,3 +1,6 @@ class Foto < ActiveRecord::Base attr_accessible :datei, :desc, :gallery_id, :title + belongs_to :gallery + mount_uploader :datei, FotoUploader + end diff --git a/app/models/gallery.rb b/app/models/gallery.rb index 746a1d1..0b0f977 100644 --- a/app/models/gallery.rb +++ b/app/models/gallery.rb @@ -1,3 +1,4 @@ class Gallery < ActiveRecord::Base attr_accessible :datum, :desc, :name + has_many :fotos end diff --git a/app/views/fotos/show.html.erb b/app/views/fotos/show.html.erb index 2a4c611..9183e5e 100644 --- a/app/views/fotos/show.html.erb +++ b/app/views/fotos/show.html.erb @@ -1,25 +1,31 @@ -

<%= notice %>

-

- Title: - <%= @foto.title %> -

+
-

- Desc: - <%= @foto.desc %> -

+ +
+
+ <%= link_to image_tag(@foto.datei.resized.url), gallery_foto_path(@foto.gallery, ((@foto.gallery.fotos[@foto.gallery.fotos.index(@foto)+1].nil?) ? (@foto.gallery.fotos[0].try(:id).to_i) : @foto.gallery.fotos[@foto.gallery.fotos.index(@foto)+1].try(:id).to_i) ) %> +
+
-

- Gallery: - <%= @foto.gallery_id %> -

+
+
+

<%= @foto.title %>

+

<%= @foto.desc %>

+
+
+

+ <%= link_to 'last' , gallery_foto_path(@foto.gallery, @foto.gallery.fotos[@foto.gallery.fotos.index(@foto)-1].try(:id).to_i) unless @foto.gallery.fotos.index(@foto)==0 %> + <%= link_to 'next' , gallery_foto_path(@foto.gallery, @foto.gallery.fotos[@foto.gallery.fotos.index(@foto)+1].try(:id).to_i) unless @foto.gallery.fotos[@foto.gallery.fotos.index(@foto)+1].nil? %> + <%= link_to 'Edit', edit_foto_path(@foto) %> | + <%= link_to 'Back', gallery_path(@foto.gallery) %> +

+
+
+
+
+

<%= notice %>

+
+
+
-

- Datei: - <%= @foto.datei %> -

- - -<%= link_to 'Edit', edit_foto_path(@foto) %> | -<%= link_to 'Back', fotos_path %> diff --git a/app/views/galleries/show.html.erb b/app/views/galleries/show.html.erb index 2fa130b..392008b 100644 --- a/app/views/galleries/show.html.erb +++ b/app/views/galleries/show.html.erb @@ -14,7 +14,14 @@ Datum: <%= @gallery.datum %>

+<% @gallery.fotos.each do |f| %> +<%= link_to image_tag(f.datei.big_thumb.url,{:class=>"img-polaroid"}) , gallery_foto_path(@gallery,f) %> + +<% end %> + + +<%= link_to 'NewFoto' , new_gallery_foto_path(@gallery) %> | <%= link_to 'Edit', edit_gallery_path(@gallery) %> | <%= link_to 'Back', galleries_path %> diff --git a/config/routes.rb b/config/routes.rb index 3cd943b..16e35ef 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -36,8 +36,10 @@ get 'verwalten/studien', :controller=>:studien, :action=>:verwalten, :as=>'studien_verwalten' resources :fetzneditions - resources :fotos - resources :galleries + resources :fotos, :except=>[:new, :show] + resources :galleries do + resources :fotos, :only=>[:new,:show] + end resources :memberships resources :gremien resources :fetprofiles