From d34e7dbf9fc4cbc414fba324e30c17c48d1ff7ef Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 4 Jun 2024 12:19:50 +1000 Subject: [PATCH] Specify accepted format on client side I don't know why, but even though the client sends http accept header for json, rails is treating it as html. This was being overridden in the route, but I want to support multiple formats next. So, we explicitly choose the format by adding it to the request path. --- .../javascripts/admin/index_utils/services/columns.js.coffee | 2 +- config/routes/admin.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/admin/index_utils/services/columns.js.coffee b/app/assets/javascripts/admin/index_utils/services/columns.js.coffee index 2d7abfcab7..aeb1a3e3b6 100644 --- a/app/assets/javascripts/admin/index_utils/services/columns.js.coffee +++ b/app/assets/javascripts/admin/index_utils/services/columns.js.coffee @@ -31,7 +31,7 @@ angular.module("admin.indexUtils").factory 'Columns', ($rootScope, $http, $injec savePreferences: (action_name) => $http method: "PUT" - url: "/admin/column_preferences/bulk_update" + url: "/admin/column_preferences/bulk_update.json" data: action_name: action_name column_preferences: (preference for column_name, preference of @columns) diff --git a/config/routes/admin.rb b/config/routes/admin.rb index 21caa2b677..4016f8a695 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -95,7 +95,7 @@ Openfoodnetwork::Application.routes.draw do resource :contents - resources :column_preferences, only: [], format: :json do + resources :column_preferences, only: [] do put :bulk_update, on: :collection end