Class: AlbumsController

Inherits:
BaseController show all
Includes:
Viewable
Defined in:
app/controllers/albums_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#advertise, #cache_action?, #footer_content, #homepage_features, #plaxo, #rss_site_index, #site_index

Methods included from BaseHelper

#add_friend_link, #ajax_spinner_for, #avatar_for, #block_to_partial, #box, #city_cloud, #clippings_link, #commentable_url, #container_title, #excerpt_with_jump, #flash_class, #forum_page?, #is_current_user_and_featured?, #jumbotron, #last_active, #more_comments_links, #page_title, #paginating_links, #possesive, #profile_completeness, #render_jumbotron, #render_widgets, #rounded, #search_posts_title, #search_user_posts_path, #show_footer_content?, #tag_auto_complete_field, #time_ago_in_words, #time_ago_in_words_or_date, #tiny_mce_init_if_needed, #tiny_mce_js, #topnav_tab, #truncate_words, #truncate_words_with_highlight, #widget

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_photosObject


95
96
97
# File 'app/controllers/albums_controller.rb', line 95

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

#createObject

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(album_params)
  @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

#destroyObject

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

#editObject

GET /albums/1/edit


39
40
41
# File 'app/controllers/albums_controller.rb', line 39

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

#newObject

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

  respond_to do |format|
    format.html # new.html.erb
    format.xml  { render :xml => @album }
  end
end

#photos_addedObject


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

#showObject

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

#updateObject

patch /albums/1 patch /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(album_params)
      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