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.
This commit is contained in:
David Cook
2024-06-04 12:19:50 +10:00
parent 2d0f206e8a
commit d34e7dbf9f
2 changed files with 2 additions and 2 deletions

View File

@@ -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)

View File

@@ -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