ï»??xml version="1.0" encoding="utf-8" standalone="yes"?>69久久精品,69视频在线观看,久久久久久久久久久一区http://www.aygfsteel.com/sshwsfc/category/17421.html1=1zh-cnTue, 27 Feb 2007 10:38:59 GMTTue, 27 Feb 2007 10:38:59 GMT60诎诎Rails吧config的幕后工äœ?/title><link>http://www.aygfsteel.com/sshwsfc/archive/2006/11/21/82487.html</link><dc:creator>差沙</dc:creator><author>差沙</author><pubDate>Tue, 21 Nov 2006 04:10:00 GMT</pubDate><guid>http://www.aygfsteel.com/sshwsfc/archive/2006/11/21/82487.html</guid><wfw:comment>http://www.aygfsteel.com/sshwsfc/comments/82487.html</wfw:comment><comments>http://www.aygfsteel.com/sshwsfc/archive/2006/11/21/82487.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/sshwsfc/comments/commentRss/82487.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/sshwsfc/services/trackbacks/82487.html</trackback:ping><description><![CDATA[ <p>诎ruby是怪匂的语法有点䞍劥圓åQŒåŠšæ€è¯­­a€é‡Œé¢äžä¹˜q™æ ·çš„语法出现。䜆是看äº?jiš£n)䞀些源码后发现åQŒä‹É甹ruby的甚法真的各有䞍同ž®±åƒå€§å®¶ä»¥å‰è¯Žçš„åQŒruby每䞪人写出来的可胜郜䞍同ã€?/p> <p>现来诎Rails里面劂䜕加蝲config的吧ã€?/p> <p>圚java里面configŸlå¯¹æ˜¯äž€äžªresource文äšgåQŒç„¶åŽé€šè¿‡è¯Õd–配眮的工具加入进来圚分析倄理ã€?/p> <p>圚ROR里面完党䞍是˜q™ä¹ˆå›žäº‹ã€?/p> <p>1.銖先倧家芁了(jiš£n)解的是圚我们启åŠ?ruby script/server 的时候rails做了(jiš£n)侀ŸpÕdˆ—的倄理最后他执行äº?font face="Arial">environment.rb</font></p> <div id="wmqeeuq" class="code_title"> <em> <font color="#990033">ruby 代码</font> </em> <br /> </div> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #000000">Rails::Initializer.run (tš©ng)do (tš©ng)</span> <span style="COLOR: #000000">|</span> <span style="COLOR: #000000">config</span> <span style="COLOR: #000000">|</span> <span style="COLOR: #000000"> (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)</span> <span style="COLOR: #008000">#</span> <span style="COLOR: #008000"> (tš©ng)˜q™é‡Œèƒœæ’入我们自å·Þqš„配眮。Â?tš©ng) (tš©ng) (tš©ng)?/span> <span style="COLOR: #008000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #000000"> (tš©ng) (tš©ng)</span> <span style="COLOR: #008000">#</span> <span style="COLOR: #008000"> (tš©ng)config. (tš©ng)之类 (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span> <span style="COLOR: #008000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #000000">end (tš©ng) (tš©ng) (tš©ng)</span> </div> <p class="alt">˜q™é‡Œçš„config其实是Initializer内郚的䞀䞪变量掌控党局的配Ÿ|®ä¿¡æ¯ïŒŒæˆ‘们可以䜿甚˜q™äžªconfig来配Ÿ|®æˆ‘们想芁的ã€?span><span>Rails::Initializer.run的源码是˜q™æ ·çš„yield再䞀‹Æ¡æ˜ŸœCÞZº†(jiš£n)他的嚁力åQŒè®©æˆ‘们圚配Ÿ|®æ–‡ä»¶äž­åŸ—以配眮config。然后实䟋化äº?jiš£n)䞀䞪initializer (tš©ng)之后åQŒæŠŠconfigäœœäØ“(fšŽ)参数䌠入äº?jiš£n)ã€?/span></span></p> <div id="wmqeeuq" class="code_title"> <em> <font color="#990033">ruby 代码</font> </em> <br /> </div> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #0000ff">def</span> <span style="COLOR: #000000"> (tš©ng)self.run(command (tš©ng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> (tš©ng):process, (tš©ng)configuration (tš©ng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> (tš©ng)Configuration.new) (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)</span> <span style="COLOR: #0000ff">yield</span> <span style="COLOR: #000000"> (tš©ng)configuration (tš©ng)</span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000"> (tš©ng)block_given? (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)initializer (tš©ng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> (tš©ng)new (tš©ng)configuration (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)initializer.send(command) (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)initializer (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />end (tš©ng) (tš©ng) (tš©ng)</span> </div> <p class="alt">我们接着埀䞋走åQŒå¯ä»¥çœ‹åˆ°initializer (tš©ng)做了(jiš£n)侀ŸpÕdˆ—的初始化工䜜åQŒåŒ…括load_path的讟定路由的初始化åQŒå’Œactiverecord的初始化。我们关å¿?jš©)的˜q˜æ˜¯é…çœ®åŠ‚äœ•èµ·äœœç”šïŒŒé‚£ä¹ˆæ¥çœ‹çœ?font face="Arial">environments目圕䞋面的配Ÿ|®æ–‡ä»¶æ˜¯åŠ‚äœ•å¯Œå…¥çš„å§ã€?/font></p> <div id="wmqeeuq" class="code_title"> <em> <font color="#990033">ruby 代码</font> </em> </div> <div id="wmqeeuq" class="dp-highlighter"> <div id="wmqeeuq" class="bar"> </div> </div> <p> <span id="wmqeeuq" class="builtin"> </span> </p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #0000ff">def</span> <span style="COLOR: #000000"> (tš©ng)load_environment (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)silence_warnings (tš©ng)do (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)config (tš©ng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> (tš©ng)configuration (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)constants (tš©ng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> (tš©ng)self.</span> <span style="COLOR: #0000ff">class</span> <span style="COLOR: #000000">.constants (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)eval(IO.read(configuration.environment_path), (tš©ng)binding) (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)(self.</span> <span style="COLOR: #0000ff">class</span> <span style="COLOR: #000000">.constants (tš©ng)</span> <span style="COLOR: #000000">-</span> <span style="COLOR: #000000"> (tš©ng)constants).each (tš©ng)do (tš©ng)</span> <span style="COLOR: #000000">|</span> <span style="COLOR: #000000">const</span> <span style="COLOR: #000000">|</span> <span style="COLOR: #000000"> (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)Object.const_set(const, (tš©ng)self.</span> <span style="COLOR: #0000ff">class</span> <span style="COLOR: #000000">.const_get(const)) (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)end (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)end (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />end (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span> </div> <p>IO<span>.read(configuration.environment_path) åQŒïŒŒ˜q™é‡Œž®×ƒžäœ¿ç”šä»€ä¹ˆå›žè°ƒäžå›žè°ƒäº?jiš£n)而是òq²è„†IO拿出来eval䞀把˜q™é‡Œä¹Ÿæ˜¯åƒäº†(jiš£n)䞀惊˜q™æ ·ä¹Ÿå¯ä»¥å‘€~~~~~~~然后åQŒæˆ‘们可以看看他倄理垞量的æ–ÒŽ(guš©)³•åQŒæŠŠè‡ªå·±é…çœ®æ–‡äšg䞭的垔R‡å…šéƒšæ”‘Ö…¥Object里面åQŒè“v到党局垔R‡çš„目的ã€?/span></p> <p> <span>最Ÿlçš„˜q˜æ˜¯<font face="Arial">initialize_framework_settingsåQŒä‹É甚了(jiš£n)有䞀䞪ruby的技巧ã€?/font></span> </p> <span> <div id="wmqeeuq" class="code_title"> <em> <font color="#990033">ruby 代码</font> </em> </div> <div id="wmqeeuq" class="bar"> </div> <p class="alt"> </p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #0000ff">def</span> <span style="COLOR: #000000"> (tš©ng)initialize_framework_settings (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)configuration.frameworks.each (tš©ng)do (tš©ng)</span> <span style="COLOR: #000000">|</span> <span style="COLOR: #000000">framework</span> <span style="COLOR: #000000">|</span> <span style="COLOR: #000000"> (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)base_class (tš©ng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> (tš©ng)framework.to_s.camelize.constantize.const_get(</span> <span style="COLOR: #800000">"</span> <span style="COLOR: #800000">Base</span> <span style="COLOR: #800000">"</span> <span style="COLOR: #000000">) (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)configuration.send(framework).each (tš©ng)do (tš©ng)</span> <span style="COLOR: #000000">|</span> <span style="COLOR: #000000">setting, (tš©ng)value</span> <span style="COLOR: #000000">|</span> <span style="COLOR: #000000"> (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)base_class.send(</span> <span style="COLOR: #800000">"</span> <span style="COLOR: #800000">#{setting}=</span> <span style="COLOR: #800000">"</span> <span style="COLOR: #000000">, (tš©ng)value) (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)end (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)end (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />end (tš©ng) (tš©ng) (tš©ng)</span> </div> <p>configuration.frameworks里面存攟的是rails䞪䞪Ÿl„äšg的名字比方诎active_record之类。然后把˜q™äžªåå­—倧写蜬换åQŒç„¶åŽç”šconstantize取埗ActiveRecord˜q™äžªModule(泚意åQŒè¿™äº›äžœè¥‰Kƒœåœšactivesupport里面呢activesupport/lib/active_support/core_ext/string/inflections.rb )。然后甚const_get取埗˜q™äžªæš¡å—çš„BaseŸc»ïŒŒä¹Ÿå°±æ˜¯ActiveRecord::Base˜q™äžªŸcÖMº†(jiš£n)åQˆäž‹é¢éƒœå«åšBaseŸc»ïŒ‰(jšª)åQŒæ‰€æœ‰çš„Rails的组仉™ƒœæ˜¯è¿™äžªå‘œåè§„则改倩我们自己想芁做䞀䞪Rails的组件加˜q›æ¥åQŒä¹Ÿå¯ä»¥˜q™æ ·åQˆäœ†æ˜¯èЁœEåŸ®ä¿®æ”¹äž€äžªæºç ïŒ‰(jšª)ã€?/p> <p>然后åQŒæˆ‘们吧config里面的内容给BaseŸc…R€‚configuration.send(framework)是调甚䞀䞪组件名¿U°çš„æ–ÒŽ(guš©)³•åQŒæ¯”方诎active_recordåQŒå°±æ˜¯åŽ»çš„config里面的active_record属性˜q™æ˜¯æœ€åŸºæœ¬çš„(jšª)åQŒé€šè¿‡åŽé¢çš„do我们可以看到config˜q”回的是䞀䞪hashåQŒç„¶åŽæŠŠhash䞭每䞀䞪keyäœœäØ“(fšŽ)变量åQŒvalueäžÞZŒ å…¥å€û|ŒŒäŒ å…¥BaseŸc…R€‚。。这里倧家应该没什么问题了(jiš£n)åQŒçœ‹çœ‹æˆ‘们的config文äšg是怎么写的吧ã€?/p> <div id="wmqeeuq" class="code_title"> <em> <font color="#990033">ruby 代码</font> </em> <br /> </div> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #008000">#</span> <span style="COLOR: #008000"> (tš©ng)Settings (tš©ng)specified (tš©ng)here (tš©ng)will (tš©ng)take (tš©ng)precedence (tš©ng)over (tš©ng)those (tš©ng)in (tš©ng)config/environment.rb (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span> <span style="COLOR: #008000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #000000"> (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #008000">#</span> <span style="COLOR: #008000"> (tš©ng)I(yšªng)n (tš©ng)the (tš©ng)development (tš©ng)environment (tš©ng)your (tš©ng)application's (tš©ng)code (tš©ng)is (tš©ng)reloaded (tš©ng)on (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span> <span style="COLOR: #008000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />#</span> <span style="COLOR: #008000"> (tš©ng)every (tš©ng)request. (tš©ng) (tš©ng)This (tš©ng)slows (tš©ng)down (tš©ng)response (tš©ng)time (tš©ng)but (tš©ng)is (tš©ng)perfect (tš©ng)for (tš©ng)development (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span> <span style="COLOR: #008000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />#</span> <span style="COLOR: #008000"> (tš©ng)since (tš©ng)you (tš©ng)don't (tš©ng)have (tš©ng)to (tš©ng)restart (tš©ng)the (tš©ng)webserver (tš©ng)when (tš©ng)you (tš©ng)make (tš©ng)code (tš©ng)changes. (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span> <span style="COLOR: #008000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #000000">config.cache_classes (tš©ng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> (tš©ng)false (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #008000">#</span> <span style="COLOR: #008000"> (tš©ng)Log (tš©ng)error (tš©ng)messages (tš©ng)when (tš©ng)you (tš©ng)accidentally (tš©ng)call (tš©ng)methods (tš©ng)on (tš©ng)nil. (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span> <span style="COLOR: #008000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #000000">config.whiny_nils (tš©ng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> (tš©ng)true (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #008000">#</span> <span style="COLOR: #008000"> (tš©ng)Enable (tš©ng)the (tš©ng)breakpoint (tš©ng)server (tš©ng)that (tš©ng)script/breakpointer (tš©ng)connects (tš©ng)to (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span> <span style="COLOR: #008000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #000000">config.breakpoint_server (tš©ng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> (tš©ng)true (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #008000">#</span> <span style="COLOR: #008000"> (tš©ng)Show (tš©ng)full (tš©ng)error (tš©ng)reports (tš©ng)and (tš©ng)disable (tš©ng)caching (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span> <span style="COLOR: #008000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #000000">config.action_controller.consider_all_requests_local (tš©ng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> (tš©ng)true (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />config.action_controller.perform_caching (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> (tš©ng)false (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />config.action_view.cache_template_extensions (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> (tš©ng)false (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />config.action_view.debug_rjs (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> (tš©ng)true (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #008000">#</span> <span style="COLOR: #008000"> (tš©ng)Don't (tš©ng)care (tš©ng)if (tš©ng)the (tš©ng)mailer (tš©ng)can't (tš©ng)send (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span> <span style="COLOR: #008000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #000000">config.action_mailer.raise_delivery_errors (tš©ng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> (tš©ng)false (tš©ng) (tš©ng) (tš©ng)</span> </div> <p class="alt">哊看着埈晕吧configž®±æ˜¯æˆ‘们的配Ÿ|®å¯¹è±¡ïŒŒæŒ‰ç…§æˆ‘们䞊面的诎法config.action_view之类framework的变量应该是䞀䞪hash才对呀åQŒåŠ‚æžœæ˜¯hash的话åQŒäžåº”该甚这æ ïL(fš¥ng)š„æ–¹åŒäŒ å…¥åQŒå¯èƒœäŒš(xš¬)ç”?config.action_view = {:debug_rjs => true}来䌠入ã€?/p> <p>OK.我们来看˜q™äžªå˜é‡åˆ°åº•是什么样的hashã€?/p> <div id="wmqeeuq" class="code_title"> <em> <font color="#990033">ruby 代码</font> </em> </div> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #0000ff">def</span> <span style="COLOR: #000000"> (tš©ng)initialize (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)<img src="http://www.aygfsteel.com/images/dot.gif" />. (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)<img src="http://www.aygfsteel.com/images/dot.gif" />. (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)</span> <span style="COLOR: #0000ff">for</span> <span style="COLOR: #000000"> (tš©ng)framework (tš©ng)</span> <span style="COLOR: #0000ff">in</span> <span style="COLOR: #000000"> (tš©ng)default_frameworks (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)self.send(</span> <span style="COLOR: #800000">"</span> <span style="COLOR: #800000">#{framework}=</span> <span style="COLOR: #800000">"</span> <span style="COLOR: #000000">, (tš©ng)OrderedOptions.new) (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)end (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />end (tš©ng) (tš©ng) (tš©ng)</span> </div> <p class="alt">圚初始化˜q™äº›å˜é‡çš„æ—¶å€™ïŒŒRailsŸl™ä»–赋å€égؓ(fšŽ)OrderedOptions.<span id="wmqeeuq" class="keyword">new。这䞪特ŒDŠçš„ŸcÕdž‹å¯èƒœž®±æ˜¯å…³é”®ã€?/span></p> <span id="wmqeeuq" class="keyword"> <div id="wmqeeuq" class="code_title"> <em> <font color="#990033">ruby 代码</font> </em> <br /> </div> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #0000ff">class</span> <span style="COLOR: #000000"> (tš©ng)OrderedOptions (tš©ng)</span> <span style="COLOR: #000000"><</span> <span style="COLOR: #000000"> (tš©ng)OrderedHash (tš©ng)</span> <span style="COLOR: #008000">#</span> <span style="COLOR: #008000">:nodoc: (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span> <span style="COLOR: #008000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #000000"> (tš©ng) (tš©ng)</span> <span style="COLOR: #0000ff">def</span> <span style="COLOR: #000000"> (tš©ng)[]</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">(key, (tš©ng)value) (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)super(key.to_sym, (tš©ng)value) (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)end (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)</span> <span style="COLOR: #0000ff">def</span> <span style="COLOR: #000000"> (tš©ng)[](key) (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)super(key.to_sym) (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)end (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)</span> <span style="COLOR: #0000ff">def</span> <span style="COLOR: #000000"> (tš©ng)method_missing(name, (tš©ng)</span> <span style="COLOR: #000000">*</span> <span style="COLOR: #000000">args) (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000"> (tš©ng)name.to_s (tš©ng)</span> <span style="COLOR: #000000">=~</span> <span style="COLOR: #000000"> (tš©ng)</span> <span style="COLOR: #000000">/</span> <span style="COLOR: #000000">(.</span> <span style="COLOR: #000000">*</span> <span style="COLOR: #000000">)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">$</span> <span style="COLOR: #000000">/</span> <span style="COLOR: #000000"> (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)self[$</span> <span style="COLOR: #000000">1</span> <span style="COLOR: #000000">.to_sym] (tš©ng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> (tš©ng)args.first (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span> <span style="COLOR: #0000ff">else</span> <span style="COLOR: #000000"> (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)self[name] (tš©ng) (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)end (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)end (tš©ng) (tš©ng) (tš©ng)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />end (tš©ng) (tš©ng) (tš©ng)</span> </div> <p class="alt">看到其䞭的玄劙了(jiš£n)么method_missing~~~åQïŒ 劂果调甚䞀äž?*=的方æ³?åQŒå°±åƒåœ“甚䌠入䞀䞪HASH的å€û|ŒŒkeyž®±æ˜¯æ–ÒŽ(guš©)³•的名字ã€?/p> <p>也就是(xš¬)<span>config.action_view.debug_rjs (tš©ng) (tš©ng)= (tš©ng)</span><span id="wmqeeuq" class="keyword">true</span><span> (tš©ng)盞圓äº?span>config.action_view[:debug_rjs] = true</span></span></p> <p> <span> <span>OK åQŒå€§äœ“䞊描述äº?jiš£n)䞀䞋可以看到œŽ€å•的䞀䞪Rails初始化已Ÿlç»™æˆ‘们展瀺äº?jiš£n)几乎党郚ruby的靓䞜之倄˜q™èƒœè¯Žæ˜ŽåQŒè¿™äžªäº®ç‚¹è‚¯å®šæ˜¯èŽ¯ç©¿rails的基本圚以后的深入研究䞭我们就胜看åˆîCº†(jiš£n)ã€?/span> </span> </p> </span> </span> <img src ="http://www.aygfsteel.com/sshwsfc/aggbug/82487.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/sshwsfc/" target="_blank">差沙</a> 2006-11-21 12:10 <a href="http://www.aygfsteel.com/sshwsfc/archive/2006/11/21/82487.html#Feedback" target="_blank" style="text-decoration:none;">发衚评论</a></div>]]></description></item><item><title>诎诎Rails吧启劚匀始ã€?/title><link>http://www.aygfsteel.com/sshwsfc/archive/2006/11/20/82401.html</link><dc:creator>差沙</dc:creator><author>差沙</author><pubDate>Mon, 20 Nov 2006 15:43:00 GMT</pubDate><guid>http://www.aygfsteel.com/sshwsfc/archive/2006/11/20/82401.html</guid><wfw:comment>http://www.aygfsteel.com/sshwsfc/comments/82401.html</wfw:comment><comments>http://www.aygfsteel.com/sshwsfc/archive/2006/11/20/82401.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/sshwsfc/comments/commentRss/82401.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/sshwsfc/services/trackbacks/82401.html</trackback:ping><description><![CDATA[ <p>äžÞZº†(jiš£n)记圕自己看Rails源码的过œE‹ïŒŒå…šçš‹è®°åœ•无废话ã€?br /><br />我们看看script/server郜干äº?jiš£n)什ä¹?/p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #000000">require (tš©ng)File.dirname(__FILE__) (tš©ng)</span> <span style="COLOR: #000000">+</span> <span style="COLOR: #000000"> (tš©ng)</span> <span style="COLOR: #000000">'</span> <span style="COLOR: #000000">/../config/boot</span> <span style="COLOR: #000000">'</span> <span style="COLOR: #000000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />require (tš©ng)</span> <span style="COLOR: #000000">'</span> <span style="COLOR: #000000">commands/server</span> <span style="COLOR: #000000">'</span> </div> <br />匕甚äº?jiš£n)boot.rb˜q™äžªæ–‡äšg。看来这䞪文件是rails启劚的入口来看看怎么回事吧ã€?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">unless (tš©ng)defined?(RAILS_ROOT)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)root_path (tš©ng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (tš©ng)File.join(File.dirname(</span><span style="COLOR: #800080">__FILE__</span><span style="COLOR: #000000">), (tš©ng)</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">..</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)unless (tš©ng)RUBY_PLATFORM (tš©ng)</span><span style="COLOR: #000000">=~</span><span style="COLOR: #000000"> (tš©ng)</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">mswin32</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)require (tš©ng)</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">pathname</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)root_path (tš©ng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (tš©ng)Pathname.new(root_path).cleanpath(true).to_s<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)end<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)RAILS_ROOT (tš©ng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (tš©ng)root_path<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />end</span></div>˜q™äž€éƒšåˆ†å®šä¹‰äº?jiš£n)RAILS_ROOT˜q™äžªŸpȝ»Ÿçš„党局变量åQŒæŒ‡å®šäº†(jiš£n)™å¹ç›®çš„æ ¹ç›®åœ•åQŒå€§å®¶å¯ä»¥åœšä»¥åŽåŽäžœçš„ä‹É甚了(jiš£n)ã€?br /><br />䞋䞀郚分是扟到railsåQŒç²—略看䞀䞋ã€?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000"> (tš©ng) (tš©ng)</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (tš©ng)File.directory?(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">#{RAILS_ROOT}/vendor/rails</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)require (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">#{RAILS_ROOT}/vendor/rails/railties/lib/initializer</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)require (tš©ng)</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">rubygems</span><span style="COLOR: #800000">'</span></div>˜q™é‡Œèƒœçœ‹åˆŽÍŒŒä»–先跑到<font color="#800000">vendor/rails<font color="#000000">åŽÀL‰Ÿrailsäº?jiš£n)˜q™å°±æ˜¯æˆ‘们äؓ(fšŽ)什么胜圚插仉™‡Œç”šrails是原因。劂果没有那么gems的干‹z…R€?br />接䞋来是初始化䞀䞋load_pathåQŒæ²¡ä»€ä¹ˆçœ‹çš„了(jiš£n)。boot.rbž®Þp¿™æ ïL(fš¥ng)š„吧ã€?br /><br />回到script/server的第二行åQŒåŒ…含了(jiš£n)<span style="COLOR: #000000">'</span><span style="COLOR: #000000">commands/server</span><span style="COLOR: #000000">'˜q™äžªæ–‡äšgåQŒè¿™äžªæ–‡ä»¶æ˜¯ä»€ä¹ˆïŒŸRails的源码里面扟吧。我们圚Rails的源码里面扟到这䞪文件ã€?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">require (tš©ng)</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">active_support</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />require (tš©ng)</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">fileutils</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />begin<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)require_library_or_gem (tš©ng)</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">fcgi</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />rescue (tš©ng)Exception<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000"> (tš©ng)FCGI (tš©ng)not (tš©ng)available</span><span style="COLOR: #008000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">end<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />server (tš©ng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (tš©ng)case (tš©ng)ARGV.first<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)when (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">lighttpd</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)ARGV.shift<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)when (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">webrick</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)ARGV.shift<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (tš©ng)RUBY_PLATFORM (tš©ng)!</span><span style="COLOR: #000000">~</span><span style="COLOR: #000000"> (tš©ng)</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">mswin</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000"> (tš©ng)</span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> (tš©ng)!silence_stderr (tš©ng){ (tš©ng)`lighttpd (tš©ng)</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">version` (tš©ng)}.blank? (tš©ng)</span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> (tš©ng)defined?(FCGI)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">lighttpd</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">webrick</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng)end<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />end<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (tš©ng)server (tš©ng)</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">webrick</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)puts (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">=> (tš©ng)Booting (tš©ng)WEBrick<img src="http://www.aygfsteel.com/images/dot.gif" /></span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)puts (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">=> (tš©ng)Booting (tš©ng)lighttpd (tš©ng)(use (tš©ng)'script/server (tš©ng)webrick' (tš©ng)to (tš©ng)force (tš©ng)WEBrick)</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />end<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />FileUtils.mkdir_p(</span><span style="COLOR: #000000">%</span><span style="COLOR: #000000">w( (tš©ng)tmp</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">sessions (tš©ng)tmp</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">cache (tš©ng)tmp</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">sockets (tš©ng)))<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />require (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">commands/servers/#{server}</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span></div></span></font></font>没想到ActiveRecord居然是圚˜q™é‡ŒåŒ•甚的˜q™äžªActiveRecord里面扩展äº?jiš£n)埈对Ruby的既有类型所以我们看源码的时候劂果发现有䞍熟æ‚(zhššn)‰çš„æ–ÒŽ(guš©)³•åQŒå°±æ¥è¿™é‡Œæ‰Ÿæ‰ŸïŒŒåœ“ç„¶åQŒçœ‹Rails的API是最奜的选择ã€?br /><br />从参æ•îCž€ç›®äº†(jiš£n)ç„?dš°ng)žŒŒæˆ‘们可以䌠入server的名字<span style="COLOR: #800000">lighttpdå’?span style="COLOR: #800000">webrick<font color="#000000">åQŒæ ¹æ®äžåŒçš„server选择䞍同的server文äšg来读取。我们还是看çœ?span style="COLOR: #800000">webrick<font color="#000000">的吧ã€?br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">require (tš©ng)</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">webrick</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />require (tš©ng)</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">optparse</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />OPTIONS (tš©ng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (tš©ng){<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng):port (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #000000">=></span><span style="COLOR: #000000"> (tš©ng)</span><span style="COLOR: #000000">3000</span><span style="COLOR: #000000">,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng):ip (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #000000">=></span><span style="COLOR: #000000"> (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">0.0.0.0</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng):environment (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #000000">=></span><span style="COLOR: #000000"> (tš©ng)(ENV[</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">RAILS_ENV</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">] (tš©ng)</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000"> (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">development</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">).dup,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng):server_root (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #000000">=></span><span style="COLOR: #000000"> (tš©ng)File.expand_path(RAILS_ROOT (tš©ng)</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">/public/</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">),<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng):server_type (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #000000">=></span><span style="COLOR: #000000"> (tš©ng)WEBrick::SimpleServer,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng):charset (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #000000">=></span><span style="COLOR: #000000"> (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">UTF-8</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng):mime_types (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #000000">=></span><span style="COLOR: #000000"> (tš©ng)WEBrick::HTTPUtils::DefaultMimeTypes<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />}<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />ARGV.options (tš©ng)do (tš©ng)</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000">opts</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)script_name (tš©ng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (tš©ng)File.basename($0)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)opts.banner (tš©ng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Usage: (tš©ng)ruby (tš©ng)#{script_name} (tš©ng)[options]</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)opts.separator (tš©ng)</span><span style="COLOR: #800000">""</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)opts.on(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">-p</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">, (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">--port=port</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">, (tš©ng)I(yšªng)nteger,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Runs (tš©ng)Rails (tš©ng)on (tš©ng)the (tš©ng)specified (tš©ng)port.</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Default: (tš©ng)3000</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">) (tš©ng){ (tš©ng)</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000">v</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000"> (tš©ng)OPTIONS[:port] (tš©ng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (tš©ng)v (tš©ng)}<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)opts.on(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">-b</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">, (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">--binding=ip</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">, (tš©ng)String,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Binds (tš©ng)Rails (tš©ng)to (tš©ng)the (tš©ng)specified (tš©ng)ip.</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Default: (tš©ng)0.0.0.0</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">) (tš©ng){ (tš©ng)</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000">v</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000"> (tš©ng)OPTIONS[:ip] (tš©ng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (tš©ng)v (tš©ng)}<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)opts.on(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">-e</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">, (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">--environment=name</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">, (tš©ng)String,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Specifies (tš©ng)the (tš©ng)environment (tš©ng)to (tš©ng)run (tš©ng)this (tš©ng)server (tš©ng)under (tš©ng)(test/development/production).</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Default: (tš©ng)development</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">) (tš©ng){ (tš©ng)</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000">v</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000"> (tš©ng)OPTIONS[:environment] (tš©ng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (tš©ng)v (tš©ng)}<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)opts.on(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">-m</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">, (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">--mime-types=filename</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">, (tš©ng)String,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Specifies (tš©ng)an (tš©ng)Apache (tš©ng)style (tš©ng)mime.types (tš©ng)configuration (tš©ng)file (tš©ng)to (tš©ng)be (tš©ng)used (tš©ng)for (tš©ng)mime (tš©ng)types</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Default: (tš©ng)none</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">) (tš©ng){ (tš©ng)</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000">mime_types_file</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000"> (tš©ng)OPTIONS[:mime_types] (tš©ng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (tš©ng)WEBrick::HTTPUtils::load_mime_types(mime_types_file) (tš©ng)}<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)opts.on(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">-d</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">, (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">--daemon</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Make (tš©ng)Rails (tš©ng)run (tš©ng)as (tš©ng)a (tš©ng)Daemon (tš©ng)(only (tš©ng)works (tš©ng)if (tš©ng)fork (tš©ng)is (tš©ng)available (tš©ng)-- (tš©ng)meaning (tš©ng)on (tš©ng)*nix).</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)) (tš©ng){ (tš©ng)OPTIONS[:server_type] (tš©ng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (tš©ng)WEBrick::Daemon (tš©ng)}<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)opts.on(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">-c</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">, (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">--charset=charset</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">, (tš©ng)String,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Set (tš©ng)default (tš©ng)charset (tš©ng)for (tš©ng)output.</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Default: (tš©ng)UTF-8</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">) (tš©ng){ (tš©ng)</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000">v</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000"> (tš©ng)OPTIONS[:charset] (tš©ng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (tš©ng)v (tš©ng)}<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)opts.separator (tš©ng)</span><span style="COLOR: #800000">""</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)opts.on(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">-h</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">, (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">--help</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Show (tš©ng)this (tš©ng)help (tš©ng)message.</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">) (tš©ng){ (tš©ng)puts (tš©ng)opts; (tš©ng)exit (tš©ng)}<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng)opts.parse!<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />end<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />ENV[</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">RAILS_ENV</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">] (tš©ng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (tš©ng)OPTIONS[:environment]<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />RAILS_ENV.replace(OPTIONS[:environment]) (tš©ng)</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (tš©ng)defined?(RAILS_ENV)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />require (tš©ng)RAILS_ROOT (tš©ng)</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">/config/environment</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />require (tš©ng)</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">webrick_server</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />OPTIONS[</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">working_directory</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">] (tš©ng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (tš©ng)File.expand_path(RAILS_ROOT)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />puts (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">=> (tš©ng)Rails (tš©ng)application (tš©ng)started (tš©ng)on (tš©ng)http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />puts (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">=> (tš©ng)Ctrl-C (tš©ng)to (tš©ng)shutdown (tš©ng)server; (tš©ng)call (tš©ng)with (tš©ng)--help (tš©ng)for (tš©ng)options</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"> (tš©ng)</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (tš©ng)OPTIONS[:server_type] (tš©ng)</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> (tš©ng)WEBrick::SimpleServer<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />DispatchServlet.dispatch(OPTIONS)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span></div></font></span></font></span></span>本来䞍想把倧ŒD늚„代码莎䞊来䜆是˜q™é‡Œé¢çš„内容可胜倧家郜比蟃关å¿?jš©)涉å?qiš¢ng)到server的启劚参数ã€?br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng):port (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)<span style="COLOR: #000000">=></span><span style="COLOR: #000000"> (tš©ng)</span><span style="COLOR: #000000">端口</span><span style="COLOR: #000000">,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng):ip (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #000000">=></span><span style="COLOR: #000000"> (tš©ng)server ip</span><span style="COLOR: #000000">,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng):environment (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #000000">=></span><span style="COLOR: #000000">˜qè¡ŒçŽ¯å¢ƒ</span><span style="COLOR: #000000">,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng):server_root (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #000000">=></span><span style="COLOR: #000000"> (tš©ng)web讉K—®çš„目圕åQˆåŸˆå€šäh问这䞪怎么改(jšª)</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng):server_type (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #000000">=></span><span style="COLOR: #000000"> (tš©ng)WEBrick::SimpleServer,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng):charset (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #000000">=></span><span style="COLOR: #000000"> (tš©ng)</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">UTF-8</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">, Ÿ~–码<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> (tš©ng) (tš©ng):mime_types (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng) (tš©ng)</span><span style="COLOR: #000000">=></span><span style="COLOR: #000000"> (tš©ng)WEBrick::HTTPUtils::DefaultMimeTypes<br /><br />后面的require (tš©ng)匕入äº?jiš£n)䞀䞪文ä»ÓžŒŒäž€äžªæ˜¯<span style="COLOR: #800000">'</span><span style="COLOR: #800000">webrick_server</span><span style="COLOR: #800000">'<font color="#000000">åQŒåˆ«çœ‹ïŒŒž®±æ˜¯ä»–。及倖䞀䞪是</font><font color="#800000">config/environment</font><font color="#000000">åQŒè¿™äžªæ–‡ä»¶æ˜¯Ÿpȝ»Ÿçš„党局配眮文äšgåQŒåŸˆé‡èЁåQŒæˆ‘们还是䞋‹Æ¡çœ‹çœ‹è¿™äžªæ–‡ä»¶åŽ»å§ã€‚é‡Œé¢è¿˜çœŸæŒºæœ‰æ„æ€ã€?br /><br />åQˆäžçŸ¥é“blogjava让䞍让写ROR的文章看到有äh写了(jiš£n)所以攟圚銖™åµäº†(jiš£n)åQŒåŠ‚æžœäžåŠ¥ïŒŒæˆ‘äŒš(xš¬)ž®œå¿«åˆ é™€åQ?/font></span></span><img src ="http://www.aygfsteel.com/sshwsfc/aggbug/82401.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/sshwsfc/" target="_blank">差沙</a> 2006-11-20 23:43 <a href="http://www.aygfsteel.com/sshwsfc/archive/2006/11/20/82401.html#Feedback" target="_blank" style="text-decoration:none;">发衚评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> Ö÷ÕŸÖ©Öë³ØÄ£°å£º <a href="http://" target="_blank">¶šœáÏØ</a>| <a href="http://" target="_blank">Ñ×ÁêÏØ</a>| <a href="http://" target="_blank">ÖзœÏØ</a>| <a href="http://" target="_blank">ÍпËÍÐÏØ</a>| <a href="http://" target="_blank">ÕþºÍÏØ</a>| <a href="http://" target="_blank">ÐÇ×ÓÏØ</a>| <a href="http://" target="_blank">ÎÚÀŒ²ì²ŒÊÐ</a>| <a href="http://" target="_blank">ÉÏÓÝÊÐ</a>| <a href="http://" target="_blank">µæœ­ÏØ</a>| <a href="http://" target="_blank">ÁùÅÌË®ÊÐ</a>| <a href="http://" target="_blank">ÁÉÑôÊÐ</a>| <a href="http://" target="_blank">·ÊÎ÷ÏØ</a>| <a href="http://" target="_blank">ÃÏÁ¬</a>| <a href="http://" target="_blank">»³ÄþÏØ</a>| <a href="http://" target="_blank">¿ªÆœÊÐ</a>| <a href="http://" target="_blank">ËïÎâÏØ</a>| <a href="http://" target="_blank">œ«ÀÖÏØ</a>| <a href="http://" target="_blank">×ÊÏªÏØ</a>| <a href="http://" target="_blank">ÄþµÂÊÐ</a>| <a href="http://" target="_blank">ÃÉÒõÏØ</a>| <a href="http://" target="_blank">Íò°²ÏØ</a>| <a href="http://" target="_blank">Î÷ÎÚ</a>| <a href="http://" target="_blank">ÃûÉœÏØ</a>| <a href="http://" target="_blank">±±°²ÊÐ</a>| <a href="http://" target="_blank">žÄÔòÏØ</a>| <a href="http://" target="_blank">¿ŠÊ²ÊÐ</a>| <a href="http://" target="_blank">ÆÕÄþÊÐ</a>| <a href="http://" target="_blank">ËþºÓÏØ</a>| <a href="http://" target="_blank">á°žÞÏØ</a>| <a href="http://" target="_blank">ÈøžÂÏØ</a>| <a href="http://" target="_blank">ºôÂױ޶ûÊÐ</a>| <a href="http://" target="_blank">ÏçÄþÏØ</a>| <a href="http://" target="_blank">µÀæÚÏØ</a>| <a href="http://" target="_blank">ͳ·¬ÊÐ</a>| <a href="http://" target="_blank">ÎÞÎýÊÐ</a>| <a href="http://" target="_blank">ºþÖÝÊÐ</a>| <a href="http://" target="_blank">ŒÎÉÆÏØ</a>| <a href="http://" target="_blank">ÎÚÀŒ²ì²ŒÊÐ</a>| <a href="http://" target="_blank">¹ãÔªÊÐ</a>| <a href="http://" target="_blank">ãòË®ÏØ</a>| <a href="http://" target="_blank">Ñ®ÑôÏØ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>