Class: FavoritesController
Instance Method Summary
collapse
#advertise, #cache_action?, #css_help, #footer_content, #homepage_features, #plaxo, #rss_site_index, #site_index
#get_matching_ui_locale, #get_sorted_langs_from_accept_header, #get_valid_lang_from_accept_header, #set_locale
#login_by_token, #update_last_seen_at
Instance Method Details
#create ⇒ Object
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
|
#destroy ⇒ Object
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
|
#index ⇒ Object
31
32
33
|
# File 'app/controllers/favorites_controller.rb', line 31
def index
@favorites = Favorite.recent.by_user(@user).page(params[:page])
end
|
#show ⇒ Object
27
28
29
|
# File 'app/controllers/favorites_controller.rb', line 27
def show
@favorite = @user.favorites.find(params[:id])
end
|