I am storing some json data in an active-record session so have created a route and controller action which renders fine in the browser but when I try and pass the route into a JavaScript function the response in browser(chrome) network tab is null
Controller
class DataFilesController < ApplicationController
def show
render json: session[:my_data]
end
end
Route
get 'data-file.json', to: 'data_files#show', as: :data_file
Javascript function (in view)
= content_for :javascript do
:javascript
accessibleAutocomplete({
element: document.querySelector('#autocomplete-wrapper'),
id: 'autocomplete',
source: openregisterPickerEngine({
url: "<%= data_file_path %>"
}),
templates: {
inputValue: inputValueTemplate,
suggestion: suggestionTemplate
}
});
null? On the Rails side (your server logs, your Browser's Network tab, do you see the request and response you were expecting?