<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>サイキョウライン &#187; Rails</title>
	<atom:link href="http://saikyoline.jp/weblog/category/rails/feed" rel="self" type="application/rss+xml" />
	<link>http://saikyoline.jp/weblog</link>
	<description>コンピュータに関係あることとか、ないこととか。</description>
	<lastBuildDate>Tue, 13 Jul 2010 15:04:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>RailsでBase64を。</title>
		<link>http://saikyoline.jp/weblog/2010/06/30/012837.html</link>
		<comments>http://saikyoline.jp/weblog/2010/06/30/012837.html#comments</comments>
		<pubDate>Tue, 29 Jun 2010 16:28:37 +0000</pubDate>
		<dc:creator>yoshuki</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://saikyoline.jp/weblog/?p=996</guid>
		<description><![CDATA[改行とるのをベタ実装してたらメソッドあったという話。
activesupport-2.3.8/lib/active_support/core_ext/base64/encoding.rb
 10         def  [...]]]></description>
			<content:encoded><![CDATA[<p>改行とるのをベタ実装してたらメソッドあったという話。</p>
<p><em><a href="http://github.com/rails/rails/blob/v2.3.8/activesupport/lib/active_support/core_ext/base64/encoding.rb">activesupport-2.3.8/lib/active_support/core_ext/base64/encoding.rb</a></em></p>
<pre class="code"><code> 10         def encode64s(value)
 11           encode64(value).gsub(/\n/, '')
 12         end</code></pre>
<p>ほっほー。</p>
]]></content:encoded>
			<wfw:commentRss>http://saikyoline.jp/weblog/2010/06/30/012837.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>本を書きました。</title>
		<link>http://saikyoline.jp/weblog/2010/04/23/012541.html</link>
		<comments>http://saikyoline.jp/weblog/2010/04/23/012541.html#comments</comments>
		<pubDate>Thu, 22 Apr 2010 16:25:41 +0000</pubDate>
		<dc:creator>yoshuki</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://saikyoline.jp/weblog/?p=979</guid>
		<description><![CDATA[


Ruby on Rails携帯サイト開発技法ソフトバンククリエイティブ(2010-04-30)ソフトバンククリエイティブ新品価格：￥ 2,940ASIN：4797358785


自分はjpmobileを使ってアプ [...]]]></description>
			<content:encoded><![CDATA[<table style="border: 1px dotted #999999; font-size: 14px; margin: 5px; text-align: left;">
<tr>
<td><a href="http://amazon.jp/dp/4797358785/saikyoline-22"><img src="http://ecx.images-amazon.com/images/I/51JwLD%2BqNiL._SL160_.jpg" width="126" height="160" alt="Ruby on Rails携帯サイト開発技法" title="Ruby on Rails携帯サイト開発技法" style="border: 0px; margin: 5px 10px 5px 5px;"/></a></td>
<td><a href="http://amazon.jp/dp/4797358785/saikyoline-22" style="text-decoration: none;"><span style="font-weight: bold;">Ruby on Rails携帯サイト開発技法</span><br/><span>ソフトバンククリエイティブ(2010-04-30)</span><br/><span>ソフトバンククリエイティブ</span><br/><span>新品価格：￥ 2,940</span><br/><span>ASIN：4797358785</span></a></td>
</tr>
</table>
<p>自分はjpmobileを使ってアプリを作る章を担当しました。書店で見かけたら手にとって頂けるとありがたいです。</p>
]]></content:encoded>
			<wfw:commentRss>http://saikyoline.jp/weblog/2010/04/23/012541.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>autotest-tmuxできてました。</title>
		<link>http://saikyoline.jp/weblog/2010/04/12/011442.html</link>
		<comments>http://saikyoline.jp/weblog/2010/04/12/011442.html#comments</comments>
		<pubDate>Sun, 11 Apr 2010 16:14:42 +0000</pubDate>
		<dc:creator>yoshuki</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://saikyoline.jp/weblog/?p=967</guid>
		<description><![CDATA[screen+vimで縦分割したときに矢印(→)やら米印(※)やら三角(▽)やらを含んだファイルで桁ずれを起こしていたのですが、対策が見つからずそのファイルは単独タブで開くという後ろ向きな手段で回避して使っていました。
 [...]]]></description>
			<content:encoded><![CDATA[<p>screen+vimで縦分割したときに矢印(→)やら米印(※)やら三角(▽)やらを含んだファイルで桁ずれを起こしていたのですが、対策が見つからずそのファイルは単独タブで開くという後ろ向きな手段で回避して使っていました。<br />
しかし先日ついに我慢できなくなって、前から気になっていた<a href="http://tmux.sourceforge.net/">tmux</a>を試してみたところ見事にこの現象が起きず、これを機に乗り換えることにしました。複数コンソールを開くだけ、というきわめて基本的な機能しか使っていなかったため、少し設定ファイルを書くだけでまったく同じように使えています。(参考として.tmux.confを貼っておきます。)</p>
<pre class="code"><code>bind-key BSpace previous-window
bind-key Space next-window
set -g default-terminal screen-256color
set -g prefix C-z
set -g status-bg colour7
set -g status-fg black
setw -g window-status-current-format &quot; #I:#W &quot;
setw -g window-status-current-bg black
setw -g window-status-current-fg white
setw -g window-status-format &quot; #I:#W &quot;</code></pre>
<p>さて、ということで必要に迫られて<a href="http://rubygems.org/gems/autotest_screen">autotest_screen</a>のtmux版である<a href="http://rubygems.org/gems/autotest-tmux">autotest-tmux</a>を作りました。<br />
screen版の区切りをアンダースコアにしたのが、githubに置かれたgemの命名規則にかち合うのを回避という理由だったため、いまはその心配がないであろうという判断でtmux版はハイフン区切りにしました。<br />
同じような環境にあるかた、お試しください。</p>
]]></content:encoded>
			<wfw:commentRss>http://saikyoline.jp/weblog/2010/04/12/011442.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apacheは知らないhttpステータスは返さない。</title>
		<link>http://saikyoline.jp/weblog/2010/02/11/132947.html</link>
		<comments>http://saikyoline.jp/weblog/2010/02/11/132947.html#comments</comments>
		<pubDate>Thu, 11 Feb 2010 04:29:47 +0000</pubDate>
		<dc:creator>yoshuki</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://saikyoline.jp/weblog/?p=921</guid>
		<description><![CDATA[正しくは、500を返す。
render :nothing =&#62; true, :status =&#62; 450
なんてことをしていて、Mongrelの開発環境だとちゃんと450が返ってくるのにApache+Pass [...]]]></description>
			<content:encoded><![CDATA[<p>正しくは、500を返す。</p>
<pre class="code"><code>render :nothing =&gt; true, :status =&gt; 450</code></pre>
<p>なんてことをしていて、Mongrelの開発環境だとちゃんと450が返ってくるのにApache+Passengerの検証環境だと500が返ってきていた。<br />
そこで原因を調べたところ、返す可能性のあるステータスコードはすべて定義されていて、それ以外は500で返している。（※ソースは後述）</p>
<p>で、なんでこんなことをしようとしているのか。Flashのアップローダを作って<a href="http://livedocs.adobe.com/flex/3_jp/langref/flash/net/FileReference.html#upload%28%29">FileReference#upload()</a>でアップロードしているのだけれど、こいつが結果をHTTPステータスでしか受け取れない。だから、結果のメッセージをサーバから返してそれを表示する、てこともできない。<br />
アップロード自体が成功したか否かを知るには200かそれ以外か、くらいで十分なんだけれど、アプリ要件（たとえば、アップロードが終わってからファイルを受け付けられない状況になってただとか、ファイルの中身を見て判断しなきゃいけないだとか）での結果を返すには、これでは足りない。<br />
結局、Apacheのソースコメントでunusedとなっていた418～421に意味を持たせ、そこを使って対応しました。層を混同していて気持ちがいいものではないのだけれど、影響範囲は広くなく、なんらかのフラグを立てて別リクエスト、のコスト増を考えるといいだろうとの判断。もしなにかいい方法があったら教えてください。</p>
<p>以下、Apacheソースの該当部分。<br />
<span id="more-921"></span><br />
<em>httpd-2.2.14/modules/http/http_protocol.c</em></p>
<pre class="code"><code> 731 AP_DECLARE(int) ap_index_of_response(int status)
 732 {
 733     static int shortcut[6] = {0, LEVEL_200, LEVEL_300, LEVEL_400,
 734     LEVEL_500, RESPONSE_CODES};
 735     int i, pos;
 736
 737     if (status &lt; 100) {               /* Below 100 is illegal for HTTP status */
 738         return LEVEL_500;
 739     }
 740
 741     for (i = 0; i &lt; 5; i++) {
 742         status -= 100;
 743         if (status &lt; 100) {
 744             pos = (status + shortcut[i]);
 745             if (pos &lt; shortcut[i + 1]) {
 746                 return pos;
 747             }
 748             else {
 749                 return LEVEL_500;            /* status unknown (falls in gap) */
 750             }
 751         }
 752     }
 753     return LEVEL_500;                         /* 600 or above is also illegal */
 754 }</code></pre>
<p><em>httpd-2.2.14/modules/http/http_protocol.c</em></p>
<pre class="code"><code>  99 #define LEVEL_400 19
 100     &quot;400 Bad Request&quot;,
 101     &quot;401 Authorization Required&quot;,
 102     &quot;402 Payment Required&quot;,
 103     &quot;403 Forbidden&quot;,
 104     &quot;404 Not Found&quot;,
 105     &quot;405 Method Not Allowed&quot;,
 106     &quot;406 Not Acceptable&quot;,
 107     &quot;407 Proxy Authentication Required&quot;,
 108     &quot;408 Request Time-out&quot;,
 109     &quot;409 Conflict&quot;,
 110     &quot;410 Gone&quot;,
 111     &quot;411 Length Required&quot;,
 112     &quot;412 Precondition Failed&quot;,
 113     &quot;413 Request Entity Too Large&quot;,
 114     &quot;414 Request-URI Too Large&quot;,
 115     &quot;415 Unsupported Media Type&quot;,
 116     &quot;416 Requested Range Not Satisfiable&quot;,
 117     &quot;417 Expectation Failed&quot;,
 118     &quot;418 unused&quot;,
 119     &quot;419 unused&quot;,
 120     &quot;420 unused&quot;,
 121     &quot;421 unused&quot;,
 122     &quot;422 Unprocessable Entity&quot;,
 123     &quot;423 Locked&quot;,
 124     &quot;424 Failed Dependency&quot;,
 125     /* This is a hack, but it is required for ap_index_of_response
 126      * to work with 426.
 127      */
 128     &quot;425 No code&quot;,
 129     &quot;426 Upgrade Required&quot;,</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://saikyoline.jp/weblog/2010/02/11/132947.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>rake notesが出してくれる範囲。</title>
		<link>http://saikyoline.jp/weblog/2010/01/19/120059.html</link>
		<comments>http://saikyoline.jp/weblog/2010/01/19/120059.html#comments</comments>
		<pubDate>Tue, 19 Jan 2010 03:00:59 +0000</pubDate>
		<dc:creator>yoshuki</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://saikyoline.jp/weblog/?p=907</guid>
		<description><![CDATA[configの下も出したかったので調べた。
rails-2.3.5/lib/source_annotation_extractor.rb
 48   # Returns a hash that maps filenames under +dirs+ (recursively) to arrays
 49   # with their annotations. Only files with annotations are included, and only
 50   # those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+
 51   # are taken into account.
 52   [...]]]></description>
			<content:encoded><![CDATA[<p>configの下も出したかったので調べた。</p>
<p><em>rails-2.3.5/lib/source_annotation_extractor.rb</em></p>
<pre class="code"><code> 48   # Returns a hash that maps filenames under +dirs+ (recursively) to arrays
 49   # with their annotations. Only files with annotations are included, and only
 50   # those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+
 51   # are taken into account.
 52   def find(dirs=%w(app lib test))
 53     dirs.inject({}) { |h, dir| h.update(find_in(dir)) }
 54   end</code></pre>
<p>ここね。</p>
]]></content:encoded>
			<wfw:commentRss>http://saikyoline.jp/weblog/2010/01/19/120059.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>rake db:seedっての。</title>
		<link>http://saikyoline.jp/weblog/2009/10/16/004040.html</link>
		<comments>http://saikyoline.jp/weblog/2009/10/16/004040.html#comments</comments>
		<pubDate>Thu, 15 Oct 2009 15:40:40 +0000</pubDate>
		<dc:creator>yoshuki</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://saikyoline.jp/weblog/?p=886</guid>
		<description><![CDATA[rake db:seed &#8211; p0t
Rails 2.3.4から入ったrake db:seed。所謂マスターデータを入れる処理はmigrationじゃなくてこっちにしようという話。
もう悩まない！
]]></description>
			<content:encoded><![CDATA[<blockquote cite="http://docs.komagata.org/4245" title="rake db:seed - p0t"><p><a href="http://docs.komagata.org/4245">rake db:seed &#8211; p0t</a></p>
<p>Rails 2.3.4から入ったrake db:seed。所謂マスターデータを入れる処理はmigrationじゃなくてこっちにしようという話。</p></blockquote>
<p>もう悩まない！</p>
]]></content:encoded>
			<wfw:commentRss>http://saikyoline.jp/weblog/2009/10/16/004040.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>autotest_screenをリリースしました。</title>
		<link>http://saikyoline.jp/weblog/2009/03/19/232758.html</link>
		<comments>http://saikyoline.jp/weblog/2009/03/19/232758.html#comments</comments>
		<pubDate>Thu, 19 Mar 2009 14:27:58 +0000</pubDate>
		<dc:creator>yoshuki</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://saikyoline.jp/weblog/?p=667</guid>
		<description><![CDATA[autotest/screenの切り出しを引き受けてから早2週間、やっとのことでリリースしました。
RubyForge: autotest_screen: Project Info
Autotest::Screen sh [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://saikyoline.jp/weblog/2009/03/04/032637.html">autotest/screenの切り出しを引き受け</a>てから早2週間、やっとのことでリリースしました。</p>
<blockquote cite="http://rubyforge.org/projects/autotest-screen/" title="RubyForge: autotest_screen: Project Info"><p><a href="http://rubyforge.org/projects/autotest-screen/">RubyForge: autotest_screen: Project Info</a></p>
<p>Autotest::Screen shows autotest/autospec progress on GNU Screen&#8217;s status line.</p></blockquote>
<p>これからは</p>
<pre class="code"><code>gem install autotest_screen</code></pre>
<p>でどうぞ。</p>
<p>RubyForgeにプロジェクト作ってファイル上げてって流れ、<a href="http://komagata.org/">komagata</a>さんの<a href="http://www.nicovideo.jp/watch/sm4188827">動画</a>がリアルでおすすめ。<br />
<iframe width="312" height="176" src="http://ext.nicovideo.jp/thumb/sm4188827" scrolling="no" style="border:solid 1px #CCC;" frameborder="0"><a href="http://www.nicovideo.jp/watch/sm4188827">【ニコニコ動画】GemCasts.12 GemをRubyForgeにアップする</a></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://saikyoline.jp/weblog/2009/03/19/232758.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ZenTest 4.0.0でautotest/screenを。</title>
		<link>http://saikyoline.jp/weblog/2009/03/04/032637.html</link>
		<comments>http://saikyoline.jp/weblog/2009/03/04/032637.html#comments</comments>
		<pubDate>Tue, 03 Mar 2009 18:26:37 +0000</pubDate>
		<dc:creator>yoshuki</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ZenTest]]></category>

		<guid isPermaLink="false">http://saikyoline.jp/weblog/?p=654</guid>
		<description><![CDATA[RubyForge: zentest-4.0.0-released
ZenTest version 4.0.0 has been released!
先日パッチを投げてみて、そのあとこんなやりとり（超訳：Ryan「おれs [...]]]></description>
			<content:encoded><![CDATA[<blockquote cite="http://rubyforge.org/forum/forum.php?forum_id=30736" title="RubyForge: zentest-4.0.0-released"><p><a href="http://rubyforge.org/forum/forum.php?forum_id=30736">RubyForge: zentest-4.0.0-released</a></p>
<p>ZenTest version 4.0.0 has been released!</p></blockquote>
<p><a href="http://saikyoline.jp/weblog/2009/02/27/034109.html">先日パッチを投げて</a>みて、そのあと<a href="http://rubyforge.org/tracker/?func=detail&#038;atid=1680&#038;aid=24165&#038;group_id=419">こんなやりとり</a>（超訳：Ryan「おれscreen使ってなくて、これからも使う予定ないから、メンテやってくれないかな。」オレ「わかった、やるよ。」）があって、autotest/screenを担当することになったのですが、その直後にリリースされた4.0.0ではもうautotest/screenが削除されております。（こんなタイミングだったとはっ！ <img src='http://saikyoline.jp/weblog/wp-includes/images/smilies/icon_eek.gif' alt='8O' class='wp-smiley' /> ）<br />
そのためZenTest 4.0.0にアップデートされた方はautotest/screenが無い状態になっていると思いますので、お困りの方のために暫定処置としてソースを張っておきます。<br />
<script src="http://gist.github.com/7766.js"></script><br />
こいつを ZenTest-4.0.0/lib/autotest/screen.rb として置くか、$HOME/.autotest にまるっと貼り付けてやればOKです。<br />
正式対応はへっぽこ英語でやりとりしつつ鋭意作業中ですので、いましばらくお待ちください。</p>
]]></content:encoded>
			<wfw:commentRss>http://saikyoline.jp/weblog/2009/03/04/032637.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>autotestにhookを。</title>
		<link>http://saikyoline.jp/weblog/2009/02/27/034109.html</link>
		<comments>http://saikyoline.jp/weblog/2009/02/27/034109.html#comments</comments>
		<pubDate>Thu, 26 Feb 2009 18:41:09 +0000</pubDate>
		<dc:creator>yoshuki</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://saikyoline.jp/weblog/?p=650</guid>
		<description><![CDATA[
シンタックスエラーやらが原因で、気がついたらscreenの裏で静かにautotestが落ちてた。
なんてことを繰り返してた。
そのためのhookを追加したらいいんじゃないかと思いつきやってみた。
去年いじったautot [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li>シンタックスエラーやらが原因で、気がついたらscreenの裏で静かにautotestが落ちてた。</li>
<li>なんてことを繰り返してた。</li>
<li>そのためのhookを追加したらいいんじゃないかと思いつきやってみた。</li>
<li>去年いじったautotest/screenがそのままになっていたのに気がついた。</li>
<li>この際一緒に投げようとした。</li>
<li>他の人が先に投げたパッチに被っていることに気がついた。</li>
<li>どうしようか考えた。</li>
<li>けれどとりあえず気にしないで投げた。←いまココ</li>
</ol>
<p>[ref.] <a href="http://saikyoline.jp/weblog/2008/08/10/013911.html">Autotest::Screenのhookを整理してみた。</a><br />
[ref.] <a href="http://rubyforge.org/tracker/?atid=1680&#038;group_id=419&#038;func=browse">RubyForge: ZenTest &#8211; Ruby Unit Testing Utility:</a></p>
]]></content:encoded>
			<wfw:commentRss>http://saikyoline.jp/weblog/2009/02/27/034109.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MerbがMerbが。</title>
		<link>http://saikyoline.jp/weblog/2008/12/25/223519.html</link>
		<comments>http://saikyoline.jp/weblog/2008/12/25/223519.html#comments</comments>
		<pubDate>Thu, 25 Dec 2008 13:35:19 +0000</pubDate>
		<dc:creator>yoshuki</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://saikyoline.jp/weblog/?p=565</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<blockquote cite="http://weblog.rubyonrails.com/2008/12/23/merb-gets-merged-into-rails-3" title="Riding Rails: Merb gets merged into Rails 3!"><p><a href="http://weblog.rubyonrails.com/2008/12/23/merb-gets-merged-into-rails-3">Riding Rails: Merb gets merged into Rails 3!</a></p>
<p>It’s christmas, baby, and do we have a present for you. We’re ending the bickering between Merb and Rails with a this bombshell: Merb is being merged into Rails 3!</p></blockquote>
<p>インストールするといっぱい依存gemが入るというくらいの知識しかなく（えぇー！）、触ってみなきゃと思いつついますぐには必要ないしという後ろ向きな理由でそのままにしていたMerbがRails3にマージされるそうです。</p>
<p>ふつうにアプリを作るならきっと現時点でもう十分で、フレームワークは道具でまた学習コストがかかるのは云々て意見も正しいと思うけど、ここをこう変えたんだとかこういう機能がついたんだというのをみるたびに、そんな方法があるんだ！とかそうやってるのか！とか感じるのが単純におもしろい。</p>
<p>包丁を研いでうわー切れるーだとか、ドリルに油さして穴開け軽々ーだとか、そういう感覚と同じなんじゃないかな。<br />
いい道具を使うことはそれ自体が楽しみで、それをメンテナンスするのも楽しいことだと思う。</p>
]]></content:encoded>
			<wfw:commentRss>http://saikyoline.jp/weblog/2008/12/25/223519.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
