Class: PinboardItemsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- PinboardItemsController
- Defined in:
- app/controllers/pinboard_items_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
- #clear ⇒ Object
-
#create ⇒ Object
POST /pinboard_items POST /pinboard_items.json.
-
#destroy ⇒ Object
DELETE /pinboard_items/1 DELETE /pinboard_items/1.json.
- #pinboard_item_params ⇒ Object private
- #set_pinboard_item ⇒ Object private
-
#update ⇒ Object
PATCH/PUT /pinboard_items/1 PATCH/PUT /pinboard_items/1.json.
-
#update_position ⇒ Object
Stub a “reorder” method.
Methods included from RedirectHelper
Methods included from RequestType
Methods included from LogRecent
Methods included from Cookies
#digest_cookie, #digested_cookie_exists?
Methods included from Whitelist
Methods included from ProjectsHelper
#cumulative_gb_per_year, #document_cumulative_gb_per_year, #document_gb_per_year, #gb_per_year, #image_cumulative_gb_per_year, #image_gb_per_year, #invalid_object, #project_classification, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form, #taxonworks_classification, #week_in_review_graphs
Methods included from Api::Intercept
Methods included from TokenAuthentication
#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate
Instance Method Details
#clear ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/pinboard_items_controller.rb', line 54 def clear if PinboardItem.clear( **params.permit(:klass).to_h .merge( user_id: sessions_current_user_id, project_id: sessions_current_project_id) .symbolize_keys) render json: {}, status: :ok else render json: {}, status: :unprocessable_entity end end |
#create ⇒ Object
POST /pinboard_items POST /pinboard_items.json
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/pinboard_items_controller.rb', line 7 def create @pinboard_item = PinboardItem.new(pinboard_item_params.merge(user_id: sessions_current_user_id)) respond_to do |format| if @pinboard_item.save format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Pinboard item was successfully created.')} format.json { render action: :show, status: :created, location: @pinboard_item } format.js {} else format.html {redirect_back(fallback_location: (request.referer || root_path), notice: "Couldn't pin this item! Is it already there?")} format.json { render json: @pinboard_item.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /pinboard_items/1 DELETE /pinboard_items/1.json
45 46 47 48 49 50 51 52 |
# File 'app/controllers/pinboard_items_controller.rb', line 45 def destroy @pinboard_item.destroy respond_to do |format| format.html { destroy_redirect @pinboard_item, notice: 'Pinboard item was successfully destroyed.' } format.json { head :no_content } format.js {} end end |
#pinboard_item_params ⇒ Object (private)
72 73 74 |
# File 'app/controllers/pinboard_items_controller.rb', line 72 def pinboard_item_params params.require(:pinboard_item).permit(:pinned_object_id, :pinned_object_type, :user_id, :is_inserted, :is_cross_project, :inserted_count) end |
#set_pinboard_item ⇒ Object (private)
68 69 70 |
# File 'app/controllers/pinboard_items_controller.rb', line 68 def set_pinboard_item @pinboard_item = PinboardItem.with_project_id(sessions_current_project_id).find(params[:id]) end |
#update ⇒ Object
PATCH/PUT /pinboard_items/1 PATCH/PUT /pinboard_items/1.json
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/pinboard_items_controller.rb', line 23 def update respond_to do |format| if @pinboard_item.update(pinboard_item_params) format.html { redirect_to @pinboard_item, notice: 'Pinboard items was successfully updated.' } format.json { render :show, location: @pinboard_item } format.js {} else format.html { render action: 'edit' } format.json { render json: @pinboard_item.errors, status: :unprocessable_entity } format.js {} end end end |
#update_position ⇒ Object
Stub a “reorder” method
38 39 40 41 |
# File 'app/controllers/pinboard_items_controller.rb', line 38 def update_position PinboardItem.reorder_by(params.require(:order)) head :ok end |