I was studying rails and following the link tutorial.
The steps in the tutorial were as follows, create a datatable that would make a request via json, the controller that would respond with the data and the data table would be populated.
At the time of the test I received the following server error: 406 Not Acceptable, and detailing the chrome error in the network tab, the following error is displayed:
ActionController :: UnknownFormat at /categories.json%20
ActionController :: UnknownFormat
app / controllers / categories_controller.rb, line 8
'' 'ruby
3 before_action: set_category, only: [: show,: edit,: update,: destroy]
4
5 # GET / categories
6 # GET /categories.json
7 def index
8 respond_to do | format | 9 format.html 10 format.json {render json: CategoryDatatable.new (view_context)} 11 end 12 end 13 '' '
I searched but could not find or find a solution.
The following is a step-by-step guide to the code if someone can help me:
View:
Coffe:Responsibleforupdatingthedatatablewhencalledbytheview
Controller-indexmethod:
Browsererror:AbaNetwork:
Detailedbrowsererror:
Inotherwords,theserverIunderstooddidnotacceptthecallviajson,butIdidnotknowhowtoacceptit.ThetutorialsorsimilarerrorsIfoundareinthesamewayandastheauthorswork.
IfImaketherequestdirectlyinthebrowser link the file is displayed without problems: {"draw": 0, "recordsTotal": 3, "recordsFiltered": 3, "data": [[1, "Test1", "Error", "Yes" "Error", "No")]]
If anyone can help me, I'll be grateful.