Module: Bpluser::SavedSearches
- Extended by:
- ActiveSupport::Concern
- Included in:
- SavedSearchesController
- Defined in:
- app/controllers/concerns/bpluser/saved_searches.rb
Instance Method Summary collapse
-
#clear ⇒ Object
Only dereferences the user rather than removing the items in case they are in the session.
-
#forget ⇒ Object
Only dereferences the user rather than removing the item in case it is in the session.
- #index ⇒ Object
- #save ⇒ Object
Instance Method Details
#clear ⇒ Object
Only dereferences the user rather than removing the items in case they are in the session
47 48 49 50 51 52 53 54 |
# File 'app/controllers/concerns/bpluser/saved_searches.rb', line 47 def clear if current_user.searches.all? { |s| s.update(user_id: nil) } && current_user.save flash[:notice] = t('blacklight.saved_searches.clear.success') else flash[:error] = t('blacklight.saved_searches.clear.failure') end redirect_to saved_searches_url end |
#forget ⇒ Object
Only dereferences the user rather than removing the item in case it is in the session
33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/concerns/bpluser/saved_searches.rb', line 33 def forget search = current_user.searches.find(params[:id]) if search.update(user_id: nil) flash[:notice] = t('blacklight.saved_searches.remove.success') else flash[:error] = t('blacklight.saved_searches.remove.failure') end redirect_back fallback_location: saved_searches_path end |
#index ⇒ Object
15 16 17 |
# File 'app/controllers/concerns/bpluser/saved_searches.rb', line 15 def index @searches = current_user.searches end |
#save ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/concerns/bpluser/saved_searches.rb', line 19 def save current_user.searches << searches_from_history.find(params[:id]) if current_user.save flash[:notice] = t('blacklight.saved_searches.add.success') else flash[:error] = t('blacklight.saved_searches.add.failure') end redirect_back fallback_location: saved_searches_path end |