0
I was studying Rails and following the tutorial https://github.com/antillas21/ajax-datatables-rails.
The tutorial steps were the following, create a datatable that would perform a request via json, the controller that would respond with the data and the data table would be populated.
At the time of testing I received the following server error: 406 Not Acceptable, and detailing the error by Chrome in the network tab, the error below 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 html format. 10 format.json { render json: Categorydatatable.new(view_context)} 11 end 12 end 13
```
I researched but could not reach or find a solution.
Follow step by step the code in case anyone can help me I’ll be grateful:
View:
Coffe: Responsible for updating the datatable when called by the view
In other words, the server I understood does not accept the call via json, but I couldn’t figure out how to make it accept. The tutorials or similar errors I found are the same and according to the authors work.
If I make the request directly in the browser http://localhost:3000/Categories.json the file is displayed smoothly: {"draw":0,"recordsTotal":3,"recordsFiltered":3,"date":[[1,"Teste1","Error","Yes"],[2,"Teste2","Improvement","Yes"],[4,"Teste3","User Error","No"]]}
If anyone can help me I’d be grateful.
Vlw friend thank you very much...I do not believe in this... a space... and thinking that the mistake was something otherworldly...
– Diego Santos