1
我對Ruby和Rails很新。dhtmlxGrid可編輯網格Errno:ECONNRESET
我用導軌3.0.9和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請求後,然後我得到一個錯誤。我的Ruby解釋器(CUI)1.9.2p290崩潰的Windows。
我該如何避免這種不穩定?
我的模型看起來像這樣:
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