# Datatable does not work in rails 7

**URL:** <https://www.ruby-forum.com/t/datatable-does-not-work-in-rails-7/263770>\
**Category:** Uncategorized\
**Created:** [April 7, 2023, 10:17am UTC](https://www.ruby-forum.com/t/datatable-does-not-work-in-rails-7/263770 "2023-04-07T10:17:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hasi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/cab0a1/32.png) [@hasi](https://www.ruby-forum.com/u/hasi)\
**Post date:** [April 7, 2023, 10:17am UTC](https://www.ruby-forum.com/t/datatable-does-not-work-in-rails-7/263770/1 "2023-04-07T10:17:31Z")

</div>

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](https://github.com/nkokkos/datatables_rails_7)  
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

---

<div class="post-metadata">

**Author:** ![robert-b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/54ee81/32.png) [@robert-b](https://www.ruby-forum.com/u/robert-b)\
**Post date:** [April 7, 2023, 10:18am UTC](https://www.ruby-forum.com/t/datatable-does-not-work-in-rails-7/263770/2 "2023-04-07T10:18:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hasi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/cab0a1/32.png) [@hasi](https://www.ruby-forum.com/u/hasi)\
**Post date:** [April 11, 2023, 9:13am UTC](https://www.ruby-forum.com/t/datatable-does-not-work-in-rails-7/263770/6 "2023-04-11T09:13:29Z")

</div>

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
