Class: FavoritesController

Inherits:
BaseController show all
Defined in:
app/controllers/favorites_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#advertise, #cache_action?, #css_help, #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, #excerpt_with_jump, #feed_icon_tag, #forum_page?, #is_current_user_and_featured?, #last_active, #more_comments_links, #page_title, #paginating_links, #possesive, #profile_completeness, #rounded, #search_posts_title, #search_user_posts_path, #show_footer_content?, #time_ago_in_words, #time_ago_in_words_or_date, #tiny_mce_init_if_needed, #topnav_tab, #truncate_words, #truncate_words_with_highlight

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

#createObject



7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/favorites_controller.rb', line 7

def create
  @favoritable = params[:favoritable_type].classify.constantize.find(params[:favoritable_id])
  @favorite = Favorite.new(:ip_address => request.remote_ip, :favoritable => @favoritable )
  @favorite.user = current_user || nil
  @favorite.save
  
  respond_to do |format|
    format.js
  end
end

#destroyObject



18
19
20
21
22
23
24
25
# File 'app/controllers/favorites_controller.rb', line 18

def destroy
  @favorite = current_user.favorites.find(params[:id])
  @favorite.destroy
  
  respond_to do |format|
    format.js
  end    
end

#indexObject



31
32
33
# File 'app/controllers/favorites_controller.rb', line 31

def index  
  @favorites = Favorite.recent.by_user(@user).page(params[:page])
end

#showObject



27
28
29
# File 'app/controllers/favorites_controller.rb', line 27

def show
  @favorite = @user.favorites.find(params[:id])
end