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, #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



90
91
92
# File 'app/controllers/albums_controller.rb', line 90

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

#createObject

POST /albums POST /albums.xml



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/albums_controller.rb', line 40

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



80
81
82
83
84
85
86
87
88
# File 'app/controllers/albums_controller.rb', line 80

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



34
35
36
# File 'app/controllers/albums_controller.rb', line 34

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

#newObject

GET /albums/new GET /albums/new.xml



24
25
26
27
28
29
30
31
# File 'app/controllers/albums_controller.rb', line 24

def new
  @album = Album.new

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

#photos_addedObject



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

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



9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/albums_controller.rb', line 9

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



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'app/controllers/albums_controller.rb', line 60

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