Class: SavedSearchesController

Inherits:
ApplicationController show all
Defined in:
vendor/plugins/blacklight/app/controllers/saved_searches_controller.rb

Instance Method Summary (collapse)

Methods inherited from ApplicationController

#current_user, #default_html_head, #error, #extra_head_content, #javascript_includes, #stylesheet_links, #user_class

Methods included from HydraAccessControlsHelper

#editor?, #reader?, #test_permission

Instance Method Details

- (Object) clear

Only dereferences the user rather than removing the items in case they are in the session[:history]



30
31
32
33
34
35
36
37
# File 'vendor/plugins/blacklight/app/controllers/saved_searches_controller.rb', line 30

def clear    
  if Search.update_all("user_id = NULL", "user_id = #{current_user.id}")
    flash[:notice] = "Cleared your saved searches."
  else
    flash[:error] = "There was a problem clearing your saved searches."
  end
  redirect_to :action => "index"
end

- (Object) destroy

Only dereferences the user rather than removing the item in case it is in the session[:history]



19
20
21
22
23
24
25
26
# File 'vendor/plugins/blacklight/app/controllers/saved_searches_controller.rb', line 19

def destroy
  if current_user.search_ids.include?(params[:id].to_i) && Search.update(params[:id].to_i, :user_id => nil)
    flash[:notice] = "Successfully removed that saved search."
  else
    flash[:error] = "Couldn't remove that saved search."
  end
  redirect_to :back
end

- (Object) index



4
5
6
# File 'vendor/plugins/blacklight/app/controllers/saved_searches_controller.rb', line 4

def index
  @searches = current_user ? Search.find_all_by_user_id(current_user.id) : []
end

- (Object) save



8
9
10
11
12
13
14
15
# File 'vendor/plugins/blacklight/app/controllers/saved_searches_controller.rb', line 8

def save    
  if Search.update(params[:id], :user_id => current_user.id)
    flash[:notice] = "Successfully saved your search."
  else
    flash[:error] = "The was a problem saving your search."
  end
  redirect_to :back
end