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

Failed to load resource: the server responded with a status of 502 #138

Closed rainyhuynh closed 4 years ago

rainyhuynh commented 4 years ago

Dear all,

I have the case when I use Datatable for 2-5 minutes over it's will show errors "Failed to load resource: the server responded with a status of 502 ()".

It seems a caching when I clear all caching in a browser it's ok but after 2-5 minutes it comes again.

Currently, I'm using caching local below

For this action in the controller

def index
    @page_title = 'Deals'

    #limit record for user
    deals = Deal.cached_all.accessible_by(current_ability)
    @datatable = Crm::DealsDatatable.new(deals: deals)

    #caching
    #fresh_when etag: @datatable
  end

And this is a collection in datatable :

collection do 
        scope = attributes[:deals].includes(:company, :user, :sales_unit, :contact, :deal_status, :consultant_company, :contractor_company, :enduser_company, :competitor_company, :responsible, :submited, :observer) if attributes[:deals] 
        scope
    end

I also change collection without caching with the information below but it does not solve the problem.

collection do 
        scope = Deal..includes(:company, :user, :sales_unit, :contact, :deal_status, :consultant_company, :contractor_company, :enduser_company, :competitor_company, :responsible, :submited, :observer) if attributes[:deals] 
        scope
    end

Please give me some idea about this issue.

Thank you so much.

rainyhuynh commented 4 years ago

I figged it out when upgraded effective_datatables (4.8.6).