Class: AlbumsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- AlbumsController
- Includes:
- Viewable
- Defined in:
- app/controllers/albums_controller.rb
Instance Method Summary collapse
- #add_photos ⇒ Object
-
#create ⇒ Object
POST /albums POST /albums.xml.
-
#destroy ⇒ Object
DELETE /albums/1 DELETE /albums/1.xml.
-
#edit ⇒ Object
GET /albums/1/edit.
-
#new ⇒ Object
GET /albums/new GET /albums/new.xml.
- #photos_added ⇒ Object
-
#show ⇒ Object
GET /albums/1 GET /albums/1.xml.
-
#update ⇒ Object
PUT /albums/1 PUT /albums/1.xml.
Methods inherited from BaseController
#advertise, #cache_action?, #css_help, #footer_content, #homepage_features, #plaxo, #rss_site_index, #site_index
Methods included from LocalizedApplication
#get_matching_ui_locale, #get_sorted_langs_from_accept_header, #get_valid_lang_from_accept_header, #set_locale
Methods included from AuthenticatedSystem
#login_by_token, #update_last_seen_at
Instance Method Details
#add_photos ⇒ Object
95 96 97 |
# File 'app/controllers/albums_controller.rb', line 95 def add_photos @album = Album.find(params[:id]) end |
#create ⇒ Object
POST /albums POST /albums.xml
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/albums_controller.rb', line 45 def create @album = Album.new(params[:album]) @album.user_id = current_user.id respond_to do |format| if @album.save if params[:go_to] == 'only_create' flash[:notice] = :album_was_successfully_created.l format.html { redirect_to(user_photo_manager_index_path(current_user)) } else format.html { redirect_to(new_user_album_photo_path(current_user, @album)) } end else format.html { render :action => 'new' } end end end |
#destroy ⇒ Object
DELETE /albums/1 DELETE /albums/1.xml
85 86 87 88 89 90 91 92 93 |
# File 'app/controllers/albums_controller.rb', line 85 def destroy @album = Album.find(params[:id]) @album.destroy respond_to do |format| format.html { redirect_to user_photo_manager_index_path(current_user) } format.xml { head :ok } end end |
#edit ⇒ Object
GET /albums/1/edit
39 40 41 |
# File 'app/controllers/albums_controller.rb', line 39 def edit @album = Album.find(params[:id]) end |
#new ⇒ Object
GET /albums/new GET /albums/new.xml
29 30 31 32 33 34 35 36 |
# File 'app/controllers/albums_controller.rb', line 29 def new @album = Album.new(params[:album]) respond_to do |format| format.html # new.html.erb format.xml { render :xml => @album } end end |
#photos_added ⇒ Object
99 100 101 102 103 104 |
# File 'app/controllers/albums_controller.rb', line 99 def photos_added @album = Album.find(params[:id]) @album.photo_ids = params[:album][:photos_ids].uniq redirect_to user_albums_path(current_user) flash[:notice] = :album_added_photos.l end |
#show ⇒ Object
GET /albums/1 GET /albums/1.xml
14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/albums_controller.rb', line 14 def show @album = Album.find(params[:id]) update_view_count(@album) if current_user && current_user.id != @album.user_id @album_photos = @album.photos.page(params[:page]).per(10) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @album } end end |
#update ⇒ Object
PUT /albums/1 PUT /albums/1.xml
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/controllers/albums_controller.rb', line 65 def update @album = Album.find(params[:id]) respond_to do |format| if @album.update_attributes(params[:album]) if params[:go_to] == 'only_create' flash[:notice] = :album_updated.l format.html { redirect_to(user_album_path(current_user, @album)) } else format.html { redirect_to(new_user_album_photo_path(current_user, @album)) } end else format.html { render :action => "edit" } format.xml { render :xml => @album.errors, :status => :unprocessable_entity } end end end |