RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: sartip
In case it might help someone, I switch from creating a class in app/datatables to use Jbuilder.
This gave me the huge advantage to use cache. I tried delegating the cache method in my class but with no success...
Here is an example:
def index @products = Products.all.page(1).per(50) end
json.sEcho params[:sEcho].to_i json.iTotalRecords @products.total_count json.iTotalDisplayRecords @products.total_count json.set! :aaData do json.array! @products, partial: 'show', as: :product end
json.cache! [product] do json.id product.id json.name product.name end
hope this helps (Im using kaminari)
In case it might help someone, I switch from creating a class in app/datatables to use Jbuilder.
This gave me the huge advantage to use cache. I tried delegating the cache method in my class but with no success...
Here is an example:
hope this helps (Im using kaminari)