Module: Blacklight::SavedSearches
- Extended by:
- ActiveSupport::Concern
- Includes:
- Configurable
- Included in:
- SavedSearchesController
- Defined in:
- app/controllers/concerns/blacklight/saved_searches.rb
Instance Attribute Summary
Attributes included from Configurable
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
- #verify_user ⇒ Object protected
Methods included from Configurable
default_configuration, default_configuration=
Instance Method Details
#clear ⇒ Object
Only dereferences the user rather than removing the items in case they are in the session
55 56 57 58 59 60 61 62 |
# File 'app/controllers/concerns/blacklight/saved_searches.rb', line 55 def clear if current_user.searches.update_all("user_id = NULL") flash[:notice] = I18n.t('blacklight.saved_searches.clear.success') else flash[:error] = I18n.t('blacklight.saved_searches.clear.failure') end redirect_to blacklight.saved_searches_url end |
#forget ⇒ Object
Only dereferences the user rather than removing the item in case it is in the session
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/concerns/blacklight/saved_searches.rb', line 34 def forget search = current_user.searches.find(params[:id]) if search.present? search.user_id = nil search.save flash[:notice] = I18n.t('blacklight.saved_searches.remove.success') else flash[:error] = I18n.t('blacklight.saved_searches.remove.failure') end if respond_to? :redirect_back redirect_back fallback_location: blacklight.saved_searches_path else # Deprecated in Rails 5.0 redirect_to :back end end |
#index ⇒ Object
13 14 15 |
# File 'app/controllers/concerns/blacklight/saved_searches.rb', line 13 def index @searches = current_user.searches end |
#save ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/concerns/blacklight/saved_searches.rb', line 17 def save current_user.searches << searches_from_history.find(params[:id]) if current_user.save flash[:notice] = I18n.t('blacklight.saved_searches.add.success') else flash[:error] = I18n.t('blacklight.saved_searches.add.failure') end if respond_to? :redirect_back redirect_back fallback_location: blacklight.saved_searches_path else # Deprecated in Rails 5.0 redirect_to :back end end |
#verify_user ⇒ Object (protected)
66 67 68 |
# File 'app/controllers/concerns/blacklight/saved_searches.rb', line 66 def verify_user flash[:notice] = I18n.t('blacklight.saved_searches.need_login') and raise Blacklight::Exceptions::AccessDenied unless current_user end |