Class | Admin::AlbumsController
In: | app/controllers/admin/albums_controller.rb
Parent: | Sadmin::BaseController

### Methods

choose_cover create destroy edit index new show update

### Public Instance methods

choose_cover()

[Source]

        # File app/controllers/admin/albums_controller.rb, line 56
    56:   def choose_cover
    57:     @album = Album.find(params[:id])
    58:     aphoto = @album.album_photos.find_by_photo_id(params[:photo_id])
    59:     previous_cover = @album.album_photos.find_by_cover_photo(true)
    60:     render :update do |page|
    61:       if aphoto.update_attributes(:cover_photo => true)
    62:         page.replace "photo_cover_#{aphoto.id}", :partial => "aphoto_cover", :locals => {:aphoto => aphoto}
    63:         if previous_cover && previous_cover.update_attributes(:cover_photo => false)
    64:           page.replace "photo_cover_#{previous_cover.id}", :partial => "aphoto_cover", :locals => {:aphoto => previous_cover}
    65:         end
    66:       end
    67:     end
    68:   end

create()

[Source]

        # File app/controllers/admin/albums_controller.rb, line 22
    22:   def create
    23:     @album = Album.new(params[:album])
    24:     if @album.save
    25:       flash[:notice] = "El album se ha creado correctamente"
    26:       redirect_to admin_album_path(@album)
    27:     else
    28:       render :action => "new"
    29:     end
    30:   end

destroy()

[Source]

        # File app/controllers/admin/albums_controller.rb, line 45
    45:   def destroy
    46:     @album = Album.find(params[:id])
    47:     if @album.destroy
    48:       flash[:notice] = "El album ha sido eliminado"
    49:       redirect_to admin_albums_path
    50:     else
    51:       flash[:error] = "El album no ha sido eliminado"
    52:       redirect_to admin_album_path(@album)
    53:     end
    54:   end

edit()

[Source]

        # File app/controllers/admin/albums_controller.rb, line 32
    32:   def edit
    33:     @album = Album.find(params[:id])
    34:   end

index()

[Source]

        # File app/controllers/admin/albums_controller.rb, line 4
     4:   def index
     5:     @albums = Album.paginate :page => params[:page], :order => "title_es"
     6:
     7:     @orphane_photos_counter = Photo.count(:conditions => "NOT EXISTS (SELECT 1 FROM album_photos WHERE album_photos.photo_id=photos.id)")
     8:     @first_orphane_photo = Photo.find(:first,
     9:       :conditions => "NOT EXISTS (SELECT 1 FROM album_photos WHERE album_photos.photo_id=photos.id)",
    10:       :order => "created_at DESC")
    11:   end

new()

[Source]

        # File app/controllers/admin/albums_controller.rb, line 18
    18:   def new
    19:     @album = Album.new
    20:   end

show()

[Source]

        # File app/controllers/admin/albums_controller.rb, line 13
    13:   def show
    14:     @album = Album.find(params[:id])
    15:     @aphotos = @album.album_photos.ordered_by_title.paginate :joins => :photo, :page => params[:page]
    16:   end

update()

[Source]

        # File app/controllers/admin/albums_controller.rb, line 36
    36:   def update
    37:     @album = Album.find(params[:id])
    38:     if @album.update_attributes(params[:album])
    39:       redirect_to admin_album_path(@album)
    40:     else
    41:       render :action => "new"
    42:     end
    43:   end

[Validate]