2014-01-25 74 views
0

我試圖讓dynatable到ajax加載json與導軌,但我得到一個錯誤,我需要幫助解釋。我如何設置?如何讓dynatable json導軌工作

CONSOLE

TypeError: 'undefined' is not an object (evaluating 'settings.dataset.records.length') 

日誌

Started GET "/subjects/index.json?page=1&perPage=10&offset=0" for 127.0.0.1 at 2014-01-25 23:20:47 +0100 
Processing by SubjectsController#index as JSON 
    Parameters: {"page"=>"1", "perPage"=>"10", "offset"=>"0"} 
    Subject Load (3.0ms) SELECT "subjects".* FROM "subjects" 
Completed 200 OK in 3035ms (Views: 0.1ms | ActiveRecord: 3.0ms) 
[2014-01-25 23:20:50] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true 

SUBJECT.JS

jQuery(document).ready(function() { 
     $('#subjects-table').dynatable({ 
     table:{ 
       defaultColumnIdStyle: 'underscore', 
     }, 

     dataset: { 
     ajax: true, 
     ajaxUrl: '/subjects/index.json', 
     ajaxOnLoad: true, 
     contentType: "application/json; charset=utf-8", 
     records: [] 

     } 

    }); 
});  

Subjects_controller

class SubjectsController < ApplicationController 

    def index 
     @subjects = Subject.all 
     respond_to do |format| 
      format.html 
      format.json {render :json => @subjects.to_json} 
     end 
    end 

end 

回答