dhtmlxGrid可编辑网格错误:ECONNRESET

时间:2012-02-03 12:31:54

标签: ruby grid webrick

我是Ruby和Rails的新手。

我使用rails 3.0.9和ruby 1.9.2

我使用了此页面上显示的dhtmlxGrid:http://www.dhtmlx.com/blog/?p=426

在网格中添加和删除几个条目后,我随机收到以下错误:     “ERROR Errno:ECONNRESET:远程主机已关闭现有连接

C:/Railsinstaller/Ruby1.9.2/lib/ruby1.9.1/webrick/httpserver.rb:56 in 'eof?'

C:/Railsinstaller/Ruby1.9.2/lib/ruby1.9.1/webrick/httpserver.rb:56 in 'run'

C:/Railsinstaller/Ruby1.9.2/lib/ruby1.9.1/webrick/server.rb:183 in 'block in start_thread'

服务器不会立即崩溃。相反,它会在一些完成的GET请求后随机崩溃。然后我从Windows得到一个错误,我的Ruby解释器(CUI)1.9.2p290崩溃了。

如何避免这种不稳定?

我的模型看起来像这样:

class Timestep < ActiveRecord::Base

has_many :prodcaps, :dependent => :destroy
has_many :demands, :dependent => :destroy
has_many :maxaddcaps, :dependent => :destroy
has_many :addcapcosts, :dependent => :destroy
validates :stepnumber,     :presence   => true
attr_accessible :stepnumber

end

时间步长控制器如下所示:

class TimestepsController < ApplicationController
 def view
 end
 def data
     @timesteps = Timestep.all()
 end
 def dbaction
     #called for all db actions
     stepnumber = params["c0"]

     @mode = params["!nativeeditor_status"]

     @id = params["gr_id"]
     case @mode
         when "inserted"
             timestep = Timestep.new
             timestep.stepnumber = stepnumber
             timestep.save!

             @tid = timestep.id

         when "deleted"
             timestep=Timestep.find(@id)
             timestep.destroy

             @tid = @id

         when "updated"
             timestep=Timestep.find(@id)
             timestep.stepnumber = stepnumber
             timestep.save!

             @tid = @id

     end
 end
end

时间步长视图是:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
    <%= render 'shared/grid_head' %>
 </head>
 <body>
     <div id="grid_here" style="width:600px; height:400px;">
     </div>
      <script type="text/javascript" charset="utf-8">
         var grid = new dhtmlXGridObject("grid_here");
         grid.setImagePath("/javascripts/codebase/imgs/");
         grid.setHeader("Zeitpunkt");
         grid.setColSorting("str");
         grid.setInitWidths("*");
         grid.setSkin("dhx_skyblue");
         grid.init();
         grid.load("/timesteps/data.xml");

         dp = new dataProcessor("/timesteps/dbaction.xml");
         dp.init(grid);
     </script>
     <input type="button" value="Add" onclick="grid.addRow(grid.uid(),'<%=Timestep.last.stepnumber+1%>'); javascript:timedRefresh(500)"> 
     <input type="button" value="Delete" onclick="grid.deleteSelectedRows(); javascript:timedRefresh(500)">
 </body>
</html>

共享标题为:

<script src="/javascripts/codebase/dhtmlxcommon.js" type="text/javascript" charset="utf-8"></script>
<script src="/javascripts/codebase/dhtmlxgrid.js" type="text/javascript" charset="utf-8"></script>
<script src="/javascripts/codebase/dhtmlxgridcell.js" type="text/javascript" charset="utf-8"></script>
<script src="/javascripts/codebase/dhtmlxdataprocessor.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="/javascripts/codebase/dhtmlxgrid.css" type="text/css" media="screen" charset="utf-8">
<link rel="stylesheet" href="/javascripts/codebase/skins/dhtmlxgrid_dhx_skyblue.css" type="text/css" media="screen" charset="utf-8">
<script type="text/javascript" charset="utf-8">
        <%#Definiere Funktion zur Aktualisierung der Seite%>
        <%#Übernommen von http://www.quackit.com/javascript/javascript_refresh_page.cfm %>
        function timedRefresh(timeoutPeriod) {
        setTimeout("location.reload(true);",timeoutPeriod);
        }
</script>

最后,data.xml.builder看起来像这样:

xml.instruct! :xml, :version=>"1.0"

 xml.tag!("rows") do
   Timestep.all.each do |timestep|
     xml.tag!("row",{ "id" => timestep.id }) do
         xml.tag!("cell", timestep.stepnumber)
     end
   end
 end

1 个答案:

答案 0 :(得分:0)

将应用程序部署到heroku后不再出现此错误。 在我看来,这只是webrick的一个问题。