Currently, I am saving some JSON data in an active-record session and have set up a route and controller action to handle this. Everything renders perfectly fine in the browser, however, when I attempt to pass the route into a JavaScript function, the response that shows up in the browser network tab (specifically Chrome) is null
.
Controller Code
class DataFilesController < ApplicationController
def show
render json: session[:my_data]
end
end
Route Configuration
get 'data-file.json', to: 'data_files#show', as: :data_file
Javascript Function Implementation (inside 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
}
});