gryphon/simple_datatables — Issue #5: support decent_exposure
Author: linoj
Created: 2011-12-04 06:28:05+00:00
State: open

hi, when i write my #search controller action as your examples, its ok

def search
@people = Person.search(params[:search]).paginate(:page => params[:page], :per_page=>params[:per_page])
respond_with @people, :locals => { :collection => @people }
end

But not when i use the decent_exposure gem,

expose(:people) { Person.search(params[:search]).paginate(:page => (params[:page] || 1), :per_page=>params[:per_page]) }
expose(:person)

def search
respond_with people, :locals => {:collection => people}
end

Looking inside application.datatables.jsonify, the first way gets instance_variables

[:@_config, :@view_renderer, :@_routes, :@people, :@_assigns, :@_controller, :@_request, :@view_flow, :@output_buffer, :@virtual_path]

but with decent_exposure, the instance_variables are

[:@_config, :@view_renderer, :@_routes, :@_resources, :@_assigns, :@_controller, :@_request, :@view_flow, :@output_buffer, :@virtual_path]

But @_resources.class is a Hash, like { :people => [array of people] } not an active relation, and never equals collection.