photomix/app/controllers/collections_controller.rb

64 lines
1.5 KiB
Ruby
Raw Normal View History

2009-06-03 01:33:39 +02:00
class CollectionsController < ApplicationController
2009-08-03 16:39:33 +02:00
before_filter :check_public_access
2012-07-24 23:26:16 +02:00
skip_before_filter :authenticate_user!, :only => [:index, :show]
2009-06-03 01:33:39 +02:00
def index
2012-07-24 23:26:16 +02:00
@collections = Collection.joins(:albums => :photos).group_for.order('collections.title')
2009-06-03 01:33:39 +02:00
respond_to do |format|
format.html
format.json { render :json => @collections }
format.xml { render :xml => @collections }
end
end
def show
2009-06-16 01:18:42 +02:00
@collection = Collection.find( params[:id] )
2012-07-24 23:26:16 +02:00
@albums = @collection.albums.order('title')
2009-06-03 01:33:39 +02:00
respond_to do |format|
format.html
format.json { render :json => @collection }
format.xml { render :xml => @collection }
format.pdf { render :pdf => @collection.title }
end
end
def new
@collection = Collection.new
end
def create
@collection = Collection.new(params[:collection])
if @collection.save
2010-10-11 16:03:34 +02:00
flash[:notice] = "Collection created! Now lets add a new album."
redirect_to new_collection_album_path(@collection)
2009-06-03 01:33:39 +02:00
else
render :action => :new
end
end
def edit
2009-06-16 01:22:51 +02:00
@collection = Collection.find( params[:id])
2009-06-03 01:33:39 +02:00
end
def update
2009-06-16 01:22:51 +02:00
@collection = Collection.find( params[:id])
2009-06-03 01:33:39 +02:00
if @collection.update_attributes(params[:collection])
2009-06-09 00:30:22 +02:00
flash[:notice] = "Collection updated!"
2009-06-03 01:33:39 +02:00
redirect_to @collection
else
render :action => :edit
end
end
def destroy
2009-06-16 01:22:51 +02:00
@collection = Collection.find( params[:id])
2009-06-03 01:33:39 +02:00
if @collection.destroy
redirect_to collections_path
else
redirect_to @collection
end
end
end