Class: Spotlight::SearchesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Spotlight::SearchesController
- Defined in:
- app/controllers/spotlight/searches_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #update ⇒ Object
- #update_all ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
22 23 24 25 |
# File 'app/controllers/spotlight/searches_controller.rb', line 22 def edit @search.title, edit_search_path(@search) @exhibit = @search.exhibit end |
#index ⇒ Object
19 20 |
# File 'app/controllers/spotlight/searches_controller.rb', line 19 def index end |
#update ⇒ Object
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_all ⇒ Object
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 |