Class: AlbumsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/albums_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/albums_controller.rb', line 20

def create
  @album = Album.new(params[:album])
  if @album.save
    flash[:notice] = "Successfully created album."
    redirect_to @album
  else
    render :action => 'new'
  end
end

#destroyObject



44
45
46
47
48
49
# File 'app/controllers/albums_controller.rb', line 44

def destroy
  @album = Album.find(params[:id])
  @album.destroy
  flash[:notice] = "Successfully destroyed album."
  redirect_to albums_url
end

#editObject



30
31
32
# File 'app/controllers/albums_controller.rb', line 30

def edit
  @album = Album.find(params[:id])
end

#indexObject



7
8
9
# File 'app/controllers/albums_controller.rb', line 7

def index
  @albums = Album.page(params[:search], params[:page])
end

#newObject



16
17
18
# File 'app/controllers/albums_controller.rb', line 16

def new
  @album = Album.new
end

#showObject



11
12
13
14
# File 'app/controllers/albums_controller.rb', line 11

def show
  @album = Album.find(params[:id], :include => :photos)
@new_photo =	Photo.new(:album_id => @album.id)
end

#updateObject



34
35
36
37
38
39
40
41
42
# File 'app/controllers/albums_controller.rb', line 34

def update
  @album = Album.find(params[:id])
  if @album.update_attributes(params[:album])
    flash[:notice] = "Successfully updated album."
    redirect_to @album
  else
    render :action => 'edit'
  end
end