require 'data_tables' DataTables.init_iruby basic_table = DataTables::DataTable.new(data: [[1,2,3], [11,12,13]] , paging: true, info: false) p 'something' # there is no table given so only javascript is generated basic_table.to_html(id = "table_id1") basic_table.show_script options = { table_options: { class: 'display', cellspacing: "0", width: "100%", table_html: " no1 no2 no3 ".html_safe } } html_code = basic_table.to_html(id='table_id1', options) # Fix me: It is showing normal html code. That means DataTables js and css is not working or loading. IRuby.html html_code # displaying css that is inicluded IRuby.display DataTables.generate_init_code_css(dependent_css=['jquery.dataTables.css']) # to add style and js in webpage DataTables.init_script t_opts = { data: [[1,1,1], [1,2,3], [11,12,13], [1,2,3], [11,12,13], [1,2,3], [11,12,13] ], pageLength: 4 } table_from_array = DataTables::DataTable.new(t_opts) table_from_array.inspect table_opts = { class: "display", cellspacing: "0", width: "50%", table_html: " Num1 Num2 Num3 " } options = { table_options: table_opts } html_code_array_sorted = table_from_array.to_html(id='table_id3', options) IRuby.html html_code_array_sorted require 'daru' @df = Daru::DataFrame.new({b: [11,12,13,14,15], a: [1,2,3,4,5], c: [11,22,33,44,55]}, order: [:a, :b, :c], index: [:one, :two, :three, :four, :five]) t = DataTables::DataTable.new(pageLength: 4) table_opts = { class: "display", cellspacing: "0", width: "100%" } options = { table_options: table_opts } options[:table_options][:table_html] = @df.to_html_thead + @df.to_html_tbody html_code2 = t.to_html(id='table_id2', options) IRuby.html html_code2