Class: AlbumsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- AlbumsController
- Defined in:
- app/controllers/albums_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
30 31 32 |
# File 'app/controllers/albums_controller.rb', line 30 def edit @album = Album.find(params[:id]) end |
#index ⇒ Object
7 8 9 |
# File 'app/controllers/albums_controller.rb', line 7 def index @albums = Album.page(params[:search], params[:page]) end |
#new ⇒ Object
16 17 18 |
# File 'app/controllers/albums_controller.rb', line 16 def new @album = Album.new end |
#show ⇒ Object
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 |
#update ⇒ Object
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 |