Closed nekapoor closed 3 years ago
Hey @nekapoor
That save state (works with a cookie) code hasn't changed in over a year and a half. I don't think this one due to any recent effective_datatables changes.
Is there a version of effective_datatables this feature definitely works on? vs the one you're on now?
To achieve this save state stuff, effective datatables sets a cookie _effective_dt
and it stores the last EffectiveDatatables.cookie_max_size
(1500 bytes) of encrypted table state. It remembers the last 3 or 4 tables and their view settings. If it goes to save another table and doesn't have room in the cookie, it'll forget the first one. A FIFO buffer.
There are some cookie gotchas, working with the cookie_domain and cookie top level length. Maybe there are some secure site cookie issues going on with your app? Maybe it's some kind of cross site request?
This is where I'd start debugging, make sure that effective_dt
cookie is being set and that 1 table is remembered at a time.
FYI, here is the code where we "load the state" for the datatable
There's actually 3 kinds of requests we care about -- a datatables AJAX request (so a search/filter kinda thing), an inline datatables request (don't worry about this one, used for inline crud) and the regular first time a page loads request.
And here's the code that loads, saves, and serializes the cookie:
Cheers
@matt-riemer thanks for the detailed response. So weird. I'm running on rails 6.1 and the cookie is not setting anytime I apply a filter of any sort. I'm going to clone this repo and check it out locally. I'll throw some log statements in the cookie.rb file to see if it's actually getting there.
will report back. Thanks again
@matt-riemer ok so here's what I found. In cookie.rb
, there's a line in load_cookie!
and save_cookie!
that reads as:
return unless view.respond_to?(:cookies)
This is where these methods are returning for me. When I comment them out, then the cookies are set and loaded properly. A couple of questions:
view
from? Hey again,
Yea, you got me thinking about this too.
That line view.respond_to?(:cookies)
should really return true. If you do view.cookies
it definitely gives you a CookieJar object.
I think that this must be a recent rails 6 or 6.1 change.
I've...fixed it
Please check out effective_datatables 4.9.1
Here's my fix:
Thank you for making this happen! :)
@matt-riemer wow, amazing. I emailed your team this a few months back but I'll say it again: I can't tell you how wonderful this gem has been for my non-profit and our partners. It has singlehandedly allowed us to reach more underserved students around the United States and provide them with 1-on-1, online tutoring they need.
So thank you for the great effort here!
Glad that this gem can be so effective and reach people all over the world. You just made this developer's day. Thanks :D
Hello!
Sorry to bug with this sort of phantom error, but our
config.save_state
is set to true and we haven't changed anything. But over the last couple of months, our filters are no longer saving.Is there a reason why this might happen? Is there a way to go about debugging?
Thanks so much