Class: Spotlight::SearchesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/spotlight/searches_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#search_action_url

Instance Method Details

#createObject



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

def create
  params_copy = params.dup
  params_copy.delete(:exhibit_id)
  @search.title = params_copy.delete(:search)[:title]
  @search.query_params = params_copy.reject { |k,v| blacklisted_search_session_params.include?(k.to_sym) or v.blank? }
  @search.save!

  redirect_to main_app.catalog_index_path, notice: "Search has been saved"
end

#destroyObject



35
36
37
38
# File 'app/controllers/spotlight/searches_controller.rb', line 35

def destroy
  @search.destroy
  redirect_to exhibit_searches_path(@search.exhibit), alert: "Search was deleted"
end

#editObject



22
23
24
25
# File 'app/controllers/spotlight/searches_controller.rb', line 22

def edit
  add_breadcrumb @search.title, edit_search_path(@search)
  @exhibit = @search.exhibit
end

#indexObject



19
20
# File 'app/controllers/spotlight/searches_controller.rb', line 19

def index
end

#updateObject



27
28
29
30
31
32
33
# File 'app/controllers/spotlight/searches_controller.rb', line 27

def update
  if @search.update params.require(:search).permit(:title, :short_description, :long_description, :featured_image)
    redirect_to exhibit_searches_path(@search.exhibit), notice: "Search has been saved"
  else
    render action: 'edit'
  end
end

#update_allObject



40
41
42
43
44
45
46
47
# File 'app/controllers/spotlight/searches_controller.rb', line 40

def update_all
  notice = if @exhibit.update search_params
    "Searches were successfully updated."
  else
    "There was an error updating the requested searches."
  end
  redirect_to :back, notice: notice
end