Controlador para los álbums de la Fototeca
# File app/controllers/albums_controller.rb, line 81 def cat @categories = Album.categories @category = Category.find(params[:id]) @title = @category.name @albums = @category.albums.with_photos.published.paginate(:per_page => 12, :order => "created_at DESC, matching_tag_counter DESC", :page => params[:page] || 1) end
# File app/controllers/albums_controller.rb, line 28 def index prepare_albums(@context, request.xhr?) respond_to do |format| format.html do if request.xhr? render :partial => '/shared/list_items', :locals => {:items => @albums, :type => 'album'}, :layout => false else render end end end end
Vista de un album de la fototeca
# File app/controllers/albums_controller.rb, line 44 def show begin @album = Album.published.find(params[:id]) rescue ActiveRecord::RecordNotFound if can_edit?("videos") @album = Album.find(params[:id]) else raise ActiveRecord::RecordNotFound end end @photos = @album.photos.ordered_by_title.paginate :page => params[:page], :per_page => 6, :conditions => ["cover_photo=?", false] if params[:photo_id] && @photo = @album.photos.find(params[:photo_id]) @photo_id = params[:photo_id] unless @photos.collect(&:id).include?(@photo_id.to_i) @photos.pop @photos << @photo end end @related_albums = Album.published.tagged_with(@album.area_tags).paginate :page => params[:p], :per_page => 8, :conditions => "album_photos_count>0", :order => "featured DESC, created_at DESC" respond_to do |format| format.html format.js { render :update do |page| page.replace 'thumbnails', :partial => '/albums/thumbnails', :locals => {:photos => @photos} end } end end