Class: Admin::BookmarksController
- Inherits:
-
AdminController
- Object
- ApplicationController
- AdminController
- Admin::BookmarksController
- Defined in:
- app/controllers/admin/bookmarks_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /bookmarks POST /bookmarks.json.
-
#destroy ⇒ Object
DELETE /bookmarks/1 DELETE /bookmarks/1.json.
-
#index ⇒ Object
GET /bookmarks GET /bookmarks.json.
Instance Method Details
#create ⇒ Object
POST /bookmarks POST /bookmarks.json
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/admin/bookmarks_controller.rb', line 23 def create @bookmark = Admin::Bookmark.find_or_create_by(user: current_user, document: @document) respond_to do |format| if @bookmark.save format.html { redirect_to admin_bookmarks_url, notice: "Bookmark was successfully created." } format.js else format.html { render :index, status: :unprocessable_entity } format.json { render json: @bookmark.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /bookmarks/1 DELETE /bookmarks/1.json
39 40 41 42 43 44 45 46 |
# File 'app/controllers/admin/bookmarks_controller.rb', line 39 def destroy Admin::Bookmark.destroy_by(user: current_user, document: @document) respond_to do |format| format.html { redirect_to admin_bookmarks_url, notice: "Bookmark was successfully destroyed." } format.js end end |
#index ⇒ Object
GET /bookmarks GET /bookmarks.json
11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/admin/bookmarks_controller.rb', line 11 def index @pagy, @bookmarks = pagy(current_user.bookmarks.where(document_type: "Kithe::Model")) respond_to do |format| format.html { render :index } # B1G CSV format.csv { send_data collect_csv(current_user.bookmarks), filename: "documents-#{Time.zone.today}.csv" } end end |