Class: BookmarksController
- Inherits:
-
CatalogController
- Object
- CatalogController
- BookmarksController
- Includes:
- Blacklight::Bookmarks
- Defined in:
- app/controllers/bookmarks_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
LOCAL OVERRIDE to render update.js.erb partial when bookmark created.
- #folder_item_actions ⇒ Object
Instance Method Details
#create ⇒ Object
LOCAL OVERRIDE to render update.js.erb partial when bookmark created
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/bookmarks_controller.rb', line 7 def create @bookmarks = params[:bookmarks].present? ? bookmark_params : default_bookmark_params current_or_guest_user.save! unless current_or_guest_user.persisted? success = @bookmarks.all? do |bookmark| next true if current_or_guest_user.bookmarks.exists?(bookmark) begin current_or_guest_user.bookmarks.create!(bookmark) next true rescue ActiveRecord::RecordInvalid break false end end if request.xhr? # success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count }}) : render(:text => "", :status => "500") success ? render(:update) : render(plain: '', status: :internal_server_error) else if @bookmarks.any? && success flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.count) elsif @bookmarks.any? flash[:error] = I18n.t('blacklight.bookmarks.add.failure', count: @bookmarks.count) end redirect_back fallback_location: bookmarks_path end end |
#folder_item_actions ⇒ Object
37 38 39 |
# File 'app/controllers/bookmarks_controller.rb', line 37 def folder_item_actions redirect_to action: 'index' end |