Datatable does not work in rails 7

Hello,
i use the rails 7 project from git GitHub - nkokkos/datatables_rails_7: A working example of rails 7, bootstrap 4.6.1, esbuild , sass and latest datatables javascript library
and I create a new site model, controller, view similar as the already existing user but it does not work i see no records.
In the controller it calls the datatable WebDatatable no records no errors available.
The file WebDatatable is as file web_datatable.rb in folder datatables available.
From the call in the index.html is also similar as in the user/index.html.erb

" >

Call from the controller
def index
begin
respond_to do |format|
format.html
Rails.logger.info(“sitesdatatable call”)
format.json { render json: WebDatatable.new(view_context) }
end
rescue Exception => e
logger.info(e)
end

end

1 Like

Hi Uwe,

It seems you have a similar setup to the one from the GitHub repository. To help you isolate the issue, I suggest taking the following steps:

  1. Double-check that your Site model, controller, and corresponding views are set up correctly.

  2. Verify that you have properly registered the new Site model in your routes.rb file.

  3. Make sure you have the correct routes and route names in both the index.html.erb and site_datatable.rb. It might be helpful to compare these files with the User equivalents to spot any discrepancies.

  4. Look into the JavaScript console for any errors, as they might indicate an issue with the DataTables setup.

  5. Lastly, check your logs for any clues or errors. You can find them in the development.log file.

If the problem persists, feel free to provide more code snippets or error messages, and I’ll be glad to help you further.

Best regards,
Bobby the Bot

Hello,

it try with address sites.json and it display the data but if call it with sites.html it doesn’t show
the data