code-and-effect / effective_datatables

An effective ActiveRecord to Datatables dsl for Ruby on Rails. Make intelligent tables quickly.
MIT License
133 stars 36 forks source link

Stuck on first datatable some doubts. #157

Closed lcuevastodoit closed 3 years ago

lcuevastodoit commented 3 years ago

Hello, excellent work, But still I need some help, because I am stuck just in the rendering of the first table of my User model. This is what it shows me image

And a second problem is that I try to see what data the UsersDatatatable model sends from the console and all the variables are empty. So I can't do a troubleshooting image

This is my datatable class

`class UsersDatatable < Effective::Datatable collection do User.all end

datatable do col :id col :email col :nombres end end`

Thanks in advance!

matt-riemer commented 3 years ago

Actually, I know what it is.

Please install the haml gem :)

Cheers

lcuevastodoit commented 3 years ago

You were right. I just needed to add gem 'haml-rails' Thanks,Now it does show me the table, but when I test the search bar in the datatable it shows me this error in browser image

In the developer tools I see that the request was made via POST to https://my.domain/datatables/users_datatable-606275255219.json But I dont have a datatables controller

matt-riemer commented 3 years ago

You shouldn't need any datatables controller. That's built in.

And that search should totally work. Is it giving you a console error you could post here? :)

lcuevastodoit commented 3 years ago

This is the console error image

matt-riemer commented 3 years ago

Hmm, I was expecting a 403 error or something. I'm not sure why it would be 404.

The datatables search ajax request isn't even hitting your server?

In my rails server, I would expect to see something like

bundle_exec_rails_server

Maybe check out:

https://github.com/code-and-effect/effective_datatables_demo

Sorry this usually just works first time :)

lcuevastodoit commented 3 years ago

It is hitting my server image

It says "ApplicationController#route_not_found as JSON"

matt-riemer commented 3 years ago

Hmm, yea perhaps you have some unique config that's preventing these requests.

Here is the routes file:

https://github.com/code-and-effect/effective_datatables/blob/master/config/routes.rb

and the controller it's calling:

https://github.com/code-and-effect/effective_datatables/blob/master/app/controllers/effective/datatables_controller.rb

There's, imho, nothing special going on in either of these that would not respond to json.

Is there something on your app raising a 404, or playing with the request formats? That ApplicationController.route_not_found must be your app code, could it be raising a 404 somehow?

lcuevastodoit commented 3 years ago

SOLVED: Dude you are an expert As you said I had this route in the routes.rb, commenting it out eliminated the problem: # match '*unmatched', to: 'application#route_not_found', via: :all

lcuevastodoit commented 3 years ago

Thanks.

matt-riemer commented 3 years ago

You're welcome! :D