diff --git a/README.rdoc b/README.rdoc index cb37720..6687c7a 100644 --- a/README.rdoc +++ b/README.rdoc @@ -89,6 +89,10 @@ In your controller: respond_with @products end +If you are getting strange results (for instance, iTotalRecords and iTotalDisplayRecords both equal 0, or entirely the wrong collection is used), you might want to specify which collection to use: + + respond_with @products, :locals => {:collection => @products} + In your search view: @products.each do |product| diff --git a/app/views/layouts/application.datatables.jsonify b/app/views/layouts/application.datatables.jsonify index 39cfc71..78ea076 100644 --- a/app/views/layouts/application.datatables.jsonify +++ b/app/views/layouts/application.datatables.jsonify @@ -1,8 +1,13 @@ total_entries = nil current_page_entries = 0 +collection ||= nil instance_variables.each do |vn| v = instance_variable_get(vn) + + # if a collection variable was specified, use it only + next if collection && collection != v + next if v.class.name.nil? if v.class.name.start_with?("MetaSearch::Searches") and v.respond_to?('size') current_page_entries = v.size