<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="ja" xmlns="http://www.w3.org/2005/Atom">
  <title>Close to the EDGE - Home</title>
  <id>tag:blog.dio.jp,2010:mephisto/</id>
  <generator uri="http://mephistoblog.com" version="0.8.0">Mephisto Drax</generator>
  <link href="http://blog.dio.jp/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://blog.dio.jp/" rel="alternate" type="text/html"/>
  <updated>2009-03-12T00:43:05Z</updated>
  <entry xml:base="http://blog.dio.jp/">
    <author>
      <name>Akira Matsuda</name>
    </author>
    <id>tag:blog.dio.jp,2009-03-11:94</id>
    <published>2009-03-11T23:42:00Z</published>
    <updated>2009-03-12T00:43:05Z</updated>
    <category term="EDGE"/>
    <category term="Rails"/>
    <link href="http://blog.dio.jp/2009/3/11/6-reasons-why-i18n-on-rails222-sucks" rel="alternate" type="text/html"/>
    <title>Rails 2.2.2&#12398;I18n&#27231;&#33021;&#12395;&#12424;&#12427;&#26085;&#26412;&#35486;&#21270;&#12364;&#12452;&#12465;&#12390;&#12394;&#12356;6&#12388;&#12398;&#29702;&#30001;</title>
<content type="html">
            &lt;p&gt;Rails 2.2から導入されたI18nモジュールだが、さすがにバージョン0.0.1だけあって、実際に日本語でアプリを作ってみると細かいところでちょっとずつイケてなかったりするところが目につく。&lt;/p&gt;

&lt;p&gt;以下に、僕が今までに気になったところを挙げてみよう。&lt;/p&gt;

&lt;h3&gt;1. ARのerror_messages_forでカラム名とメッセージの間に半角スペースが入る&lt;/h3&gt;

&lt;p&gt;active_record-2.2.2/lib/active_record/validations.rb 208行目より抜粋&lt;/p&gt;

&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;span class=&quot;line-numbers&quot;&gt;  1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;full_messages &amp;lt;&amp;lt; attr_name + ' ' + message
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;半角スペースハードコード！！
このおかげで、例えば、「名前」カラムの必須チェックのメッセージが&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;「名前 を入力してください。」&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;というように表示されてしまう。半角スペースがめちゃめちゃ気になりますよね。&lt;/p&gt;

&lt;p&gt;そこで、&lt;a href=&quot;http://rails.lighthouseapp.com/projects/8994/tickets/1294-add-word-separator-for-ar-error-messages&quot;&gt;こんなチケット&lt;/a&gt;をあげて超いいかげんなパッチを投げてみたところ、どうやらそのままコミットされてしまったようだ。&lt;/p&gt;

&lt;p&gt;これは、上記でハードコードされた半角スペースをリソースに出しちゃって各ロケールで再定義できるようにしちゃおう、という強引な解決法で、たとえば日本語だったら&lt;/p&gt;

&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;span class=&quot;line-numbers&quot;&gt;  1&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  2&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  3&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  4&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;activerecord:
    errors:
      format:
        separator: &amp;quot;&amp;quot;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;な感じで空文字を設定してやると、無事に
「名前を入力してください。」
が出力できるようになる。
どんな言語でも &#8217; &#8217; か &#8221; 以外の文字がここに設定されることは無いような気がするので、かなりムダな拡張ではあるのだが、他の部分のキー名との整合性を考えるとこんな感じにならざるを得ないところか。&lt;br /&gt;
どなたか他にもっと自然な実装があったら教えてください。Rails 2.3はまだRCだから今なら変更可能かもしれません。&lt;/p&gt;

&lt;h3&gt;2. Array#to_sentenceで半角スペースが入る&lt;/h3&gt;

&lt;p&gt;ActiveSupportには、Array#to_sentence という、少なくとも日本語のアプリでは誰も使ってないと思われるマイナー(かつ、&lt;a href=&quot;http://www.rubyist.net/~matz/20070303.html#p01&quot;&gt;Matzいわく、「&lt;em&gt;ブレーキが壊れてる&lt;/em&gt;」&lt;/a&gt;)な機能がある。&lt;br /&gt;
で、Rails I18nプロジェクトでは当然これもローカライズの対象だったわけだが、Rails 2.2.2の実装では、どんなロケールでも&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;&#8217;, &#8217;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;でつなぐのは決め打ちで、最後の要素をつなぐフレーズだけandだったりetだったりundだったりできる、というだけ。で、「最後の要素の前に『カンマ』を入れるかどうか」をskip_last_comma ていう値で指定できるようになっていた。&lt;br /&gt;
これについては、もうちょっと汎用的にしようよ、ということで、&#8217;, &#8217; の部分も含めてロケールごとに設定できるように変更した&lt;a href=&quot;http://rails.lighthouseapp.com/projects/8994/tickets/1397-arrayto_sentencelocale-asia-improvement&quot;&gt;パッチを送りつけてみた&lt;/a&gt;。
これで、Rails 2.3だと無事にこういうふうになった。&lt;/p&gt;

&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;span class=&quot;line-numbers&quot;&gt;  1&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&amp;gt;&amp;gt; %w[部屋 Yシャツ 私].to_sentence
=&amp;gt; &amp;quot;部屋とYシャツと私&amp;quot;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;あんま嬉しくない？&lt;/p&gt;

&lt;h3&gt;3. 容量の単位のやつで半角スペースが入る&lt;/h3&gt;

&lt;p&gt;これもマイナーな機能なのでどうせ誰も使ってないだろうし、なんか説明がめんどくさくなってきたから簡単に書くと、以下のような機能があるのだが、&lt;/p&gt;

&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;span class=&quot;line-numbers&quot;&gt;  1&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&amp;gt;&amp;gt; helper.number_to_human_size 1024 * 1024 * 100
=&amp;gt; &amp;quot;100 MB&amp;quot;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;これもRails 2.2.2では数値と単位の間の半角スペースがハードコードされていたのが、&lt;a href=&quot;http://groups.google.com/group/rails-i18n/browse_thread/thread/e3c54ea6e69b3d4/9d7f84525e3ef5ae&quot;&gt;こちらの掲示板&lt;/a&gt;で「どうよ？」って訊かれたので、「日本人的にはスペース空かないほうが嬉しい」って要望を伝えたら、そのとおりに実装してくれた。&lt;br /&gt;
なので、Rails 2.3からは &lt;/p&gt;

&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;span class=&quot;line-numbers&quot;&gt;  1&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&amp;gt;&amp;gt; helper.number_to_human_size 10000
=&amp;gt; &amp;quot;9.8キロバイト&amp;quot;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;とかそんなふうに出力できるようになってます。GJ, Yaroslav!&lt;/p&gt;

&lt;h3&gt;4. Ruby 1.9に対応してない&lt;/h3&gt;

&lt;p&gt;Rails 2.2のI18nモジュールはRubyの最新安定版である1.9系では動作しない。&lt;br /&gt;
が、&lt;a href=&quot;http://github.com/rails/rails/commit/943d64b1c857944666bff2572857abe866615274&quot;&gt;このへん&lt;/a&gt;のコミットで、Rails 2.3.1ぐらいからやっと Ruby 1.9に対応できたはず。&lt;a href=&quot;http://github.com/rails/rails/blob/943d64b1c857944666bff2572857abe866615274/activesupport/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb#L260&quot;&gt;こんにちは、ゆきひろさん！&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;5. datetime_selectが致命的にダサい&lt;/h3&gt;

&lt;p&gt;I18n.locale = :ja 状態で Svenのリポジトリ内の日本語リソースファイルを使って date_selectやdatetime_selectを表示してみると、以下のような感じで、致命的にダサくて悲しいコントロールが描画される。
&lt;br /&gt;
これを解消するにはまぁとりあえず&lt;/p&gt;

&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;span class=&quot;line-numbers&quot;&gt;  1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;ja.date.abbr_month_names を [~, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;とかにしてやると「月」は出なくなるのだが、これでも数字っぽいドロップダウンが3つとか並んでるだけで、なんのコントロールなんだかよくわからない。やっぱり日本人向けにはドロップダウンの間に「年」とか「月」とかっていう字が入ってるコントロールが欲しいわけだが、これはさすがに日本ローカル過ぎてActionPackに入れてもらうには無理がある。&lt;br /&gt;
つまり、今のRailsの標準部品ではどうやっても僕らが望む形のdate_selectは作れないので、&lt;em&gt;日付のヘルパーには&lt;a href=&quot;http://d.hatena.ne.jp/elm200/20090222/1235276873&quot;&gt;elm200さんのdatetime_helper_ja&lt;/a&gt;を使う&lt;/em&gt;がよいです。datetime_helper_jaはRails 2.3でもばっちり動作します。&lt;/p&gt;

&lt;h3&gt;6. YAMLファイルを手で書くのがつらすぎる&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://github.com/amatsuda/i18n_generators/&quot;&gt;i18n_generators&lt;/a&gt;を使えばいいと思うよ。i18n_generatorsはRails 2.3にも完全対応しています。  &lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;./script/generate i18n ja&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;結論&lt;/h1&gt;

&lt;p&gt;というわけで結論。&lt;br /&gt;
Rails 2.2系で日本語なアプリを作ってる人は、上記のようにI18nがいろいろアレでイマイチなので、とっとと2.3に移行しちゃうがよいと思います。&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.dio.jp/">
    <author>
      <name>Akira Matsuda</name>
    </author>
    <id>tag:blog.dio.jp,2009-02-23:89</id>
    <published>2009-02-23T11:11:00Z</published>
    <updated>2009-02-23T11:19:24Z</updated>
    <category term="Asakusa.rb"/>
    <category term="EDGE"/>
    <category term="Ruby"/>
    <category term="events"/>
    <link href="http://blog.dio.jp/2009/2/23/we-use-ruby191-in-asakusa" rel="alternate" type="text/html"/>
    <title>&#27973;&#33609;&#12391;&#12399;Ruby 1.9.1&#12434;&#20351;&#12387;&#12390;&#12414;&#12377;</title>
<content type="html">
            &lt;p&gt;先週行われた&lt;a href=&quot;http://www.ospn.jp/osc2009-spring/&quot;&gt;OSC Tokyo 2009/Spring&lt;/a&gt;の日本Rubyの会のコマで、3週間ほど前にリリースされた新しいRuby、Ruby 1.9.1について、Ruby 1.9コンサルタント(自称)としてお話をしてきた。  &lt;/p&gt;

&lt;h3&gt;&lt;a href=&quot;http://www.ospn.jp/osc2009-spring/modules/eguide/event.php?eid=53&quot;&gt;浅草ではRuby 1.9.1を使ってます&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;資料はこちら。&lt;/p&gt;

&lt;div&gt;&lt;a href=&quot;http://www.slideshare.net/a_matsuda/ruby-191?type=powerpoint&quot; title=&quot;浅草ではRuby 1.9.1を使ってます&quot;&gt;浅草ではRuby 1.9.1を使ってます&lt;/a&gt;&lt;div&gt;View more &lt;a href=&quot;http://www.slideshare.net/&quot;&gt;presentations&lt;/a&gt; from &lt;a href=&quot;http://www.slideshare.net/a_matsuda&quot;&gt;Akira Matsuda&lt;/a&gt;. (tags: &lt;a href=&quot;http://slideshare.net/tag/ruby&quot;&gt;ruby&lt;/a&gt; &lt;a href=&quot;http://slideshare.net/tag/1-9&quot;&gt;1.9&lt;/a&gt;)&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;今回は新機能などをいちいち細かく紹介するのはやめて、もっとざっくりと全体像をなるべくユーザーの視点から語ってみることにした。
つまり、今あなたがRuby 1.9.1をダウンロードしてインストールして毎日のスクリプティングに使い始めると何が嬉しいのか？何が楽しいのか？どんな良いことがあるのか？というのがメインテーマ。&lt;br /&gt;
事実、僕自身は毎日Ruby 1.9を使っていて非常に楽しい思いをさせてもらっているし、この機会にその楽しさをみんなに伝えたい、と思ったのだが、それって、何か理由を一つ挙げるとすると何故なんだろう？と考えてみると意外に説明が難しい。&lt;br /&gt;
で、僕なりに考え直してみた結果が、EnumeratorがどうしたとかVMがどうしたとかそういう難しいところじゃなくて(そういうのはささだ先生にお任せして)、「新しいことはいいことだ」で語った内容だと思う。&lt;br /&gt;
(&lt;em&gt;以下、デンパ注意&lt;/em&gt;)&lt;/p&gt;

&lt;p&gt;&#8220;Ruby&#8221;は人類の英知の結晶だ。&#8221;Ruby&#8221;は単にいちプログラミング言語の名前であるのみならず、僕らプログラマーが世の中をもっと良いものにしていく社会的ムーヴメントだ。&lt;br /&gt;
Rubyは、プログラミング言語としては必ずしもコンピューターサイエンス的な意味で最高に高度なものではないかも知れないが、どこかの大企業が自社製品を売り込むための思惑が込められているわけでもなければ、誰かの気まぐれな思いつき「だけ」で成り立っているわけでもなく、その代わりに、ユーザーがもっと楽しく、もっと豊かにプログラミングができるようにしたい！というみんなの想いがこれ以上ないぐらい高い密度で凝縮されてできている。&lt;br /&gt;
(特に太平洋の向こう側に住んでいる)一部の心ないRailerたちが過去のRubyの一部を切り取った&#8221;Ruby 1.8.6&#8221;という言語にしがみつこうとしているとかいうような話もあるようだが、おそらく彼らの曇った目にはRubyが&#8221;ちょっと仕事を便利にしてくれるプログラミング言語&#8221;というぐらいにしか映っていないのだろう。&lt;br /&gt;
でも僕らはそうじゃない。今たまたま日本に生まれてプログラマーという人生を選んでRubyという言語に出会ったおかげで、僕らはこの魔法のかかったムーヴメントの真っただ中に身を置くことができる。新しいRubyが毎日作り出されていく奇跡を肌で感じることができる。&lt;br /&gt;
さらに、何かしらの形で自分なりのアウトプットを先っちょのほうに投げ込んでみることによって、自分の中の何かがそんな魔法を作り出すエネルギーに変わって世界中を幸せにできたりするかも知れない。この&#8221;Ruby&#8221;という、世界中を巻き込みつつ未だかつてない規模で進行している「祭り」にリアルタイムで遭遇したというこのチャンスにあなたも参加しないなんてもったいない！&lt;br /&gt;
これが、あなたが今すぐにRuby 1.9.1を使い始めるべき最大の理由だ。&lt;/p&gt;

&lt;p&gt;というようなことを語ろうと思ったけど、朝イチで眠かったし、ちょっと宗教じみてるかなー、とか思って自重してしまったっていうのもあったし、あと満員御礼(笑)で若干テンションが下がった、ってのもあって、ちょっと電波力を抑えすぎてしまったかな、と今では反省している。次の機会があったらもっと本気で電波出すことにしよう。&lt;/p&gt;

&lt;p&gt;とにかく、あれを聞いて一人でも「&lt;a href=&quot;http://www.ruby-lang.org/ja/downloads/&quot;&gt;Ruby 1.9.1をインストール&lt;/a&gt;してみたよ！」とか「&lt;a href=&quot;http://asakusa.rubyist.net&quot;&gt;Asakusa.rb&lt;/a&gt;入りたい！」とか言ってくださる人が居たらいいなぁ。&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.dio.jp/">
    <author>
      <name>Akira Matsuda</name>
    </author>
    <id>tag:blog.dio.jp,2009-01-30:84</id>
    <published>2009-01-30T01:13:00Z</published>
    <updated>2009-01-30T01:54:29Z</updated>
    <category term="EDGE"/>
    <category term="Rails"/>
    <category term="Ruby"/>
    <category term="events"/>
    <link href="http://blog.dio.jp/2009/1/30/sendairubykaigi01" rel="alternate" type="text/html"/>
    <title>&#20185;&#21488;Ruby&#20250;&#35696;01</title>
<content type="html">
            &lt;p&gt;&lt;a href=&quot;http://regional.rubykaigi.org/sendai01&quot;&gt;仙台RubyKaigi01&lt;/a&gt;に参加した。仙台は、牛タンだけじゃなくて海の幸もすこぶるウマい素敵な街だった。&lt;br /&gt;
で、「&lt;em&gt;Rails 2.3(もしくはMerb)で5分で作るトランプゲーム(仮)&lt;/em&gt;」というタイトルでLTした。とりあえず資料は以下。&lt;/p&gt;

&lt;div&gt;&lt;a href=&quot;http://www.slideshare.net/a_matsuda/rails-23merb5-presentation?type=powerpoint&quot; title=&quot;Rails 2.3(もしくはMerb)で5分で作るトランプゲーム(仮)&quot;&gt;Rails 2.3(もしくはMerb)で5分で作るトランプゲーム(仮)&lt;/a&gt;&lt;div&gt;View more &lt;a href=&quot;http://www.slideshare.net/&quot;&gt;presentations&lt;/a&gt; or &lt;a href=&quot;http://www.slideshare.net/upload?type=powerpoint&quot;&gt;upload&lt;/a&gt; your own. (tags: &lt;a href=&quot;http://slideshare.net/tag/sendairubykaigi01&quot;&gt;sendairubykaigi01&lt;/a&gt; &lt;a href=&quot;http://slideshare.net/tag/lt&quot;&gt;lt&lt;/a&gt;)&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;ほんとうはRails 2.3というフレームワークの上で動くネットワーク対戦型トランプゲームフレームワーク、というという題材で、いかに業務ロジックを再利用可能なメタなフレームワーク部分とRubyっぽいDSL(Rails的な意味で)に分けて設計／実装できるか、というのが当初の構想で、いちおうその後の懇親会で見せたとおり、そのためのデモアプリも完成してはいたんだけど、素振りしてみたらこんなのを5分でデモを交えつつ喋るのはぜんぜんムリ、ということがわかったので、急遽方針変更してデモはばっさり落としてしまった。&lt;/p&gt;

&lt;p&gt;結局、単に「&lt;big&gt;&lt;strong&gt;メタとベタ&lt;/strong&gt;&lt;/big&gt;」というフレーズ(1週間前の&lt;a href=&quot;http://wiki.fdiary.net/rails/?RailsMeetingTokyo-0037&quot;&gt;Rails勉強会&lt;/a&gt;の懇親会で&lt;a href=&quot;http://d.hatena.ne.jp/iR3/&quot;&gt;福井さん&lt;/a&gt;から聞いた)が使いたかっただけなんちゃうか的な感じになっちゃって、ちょっと内容が薄かったかな、と反省。&lt;/p&gt;

&lt;p&gt;ちなみに、この問題のスライドだけど、&lt;br /&gt;
&lt;br /&gt;
これは自分で書いたわけじゃなくて、「会社を紹介するスライドをなんかください」って会社の人に言ったらこんなのが出てきた、という。
そんなわけで、もう一度言っとくけど、&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;&lt;big&gt;どうやら&lt;a href=&quot;http://www.tafc.co.jp/&quot;&gt;T&amp;amp;Fカンパニー&lt;/a&gt;という会社で&lt;strong&gt;フェロー&lt;/strong&gt;(笑)をやってることになってます。&lt;/big&gt;&lt;br /&gt;
    よろしくお願いします。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;あと、「トランプゲーム」そのものをえらく楽しみにしててくださった方もいたようで、&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;『トランプの「ト」の字もでてこなかったじゃないかー』&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;と、あとで大場&lt;a href=&quot;http://ko.meadowy.net/~nay/diary/&quot;&gt;nay3&lt;/a&gt;にお叱りを受けてしまった。どうもすいません。&lt;/p&gt;

&lt;p&gt;いちおう、そっちのほうはもうちょっとコードが整理できたら&lt;a href=&quot;http://github.com/amatsuda/&quot;&gt;GitHub&lt;/a&gt;に上げとくので、興味がある方は是非ご覧ください。&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.dio.jp/">
    <author>
      <name>Akira Matsuda</name>
    </author>
    <id>tag:blog.dio.jp,2008-12-10:75</id>
    <published>2008-12-10T00:02:00Z</published>
    <updated>2008-12-16T01:11:56Z</updated>
    <category term="Rails"/>
    <category term="events"/>
    <link href="http://blog.dio.jp/2008/12/10/2008-rakuten2008-lt" rel="alternate" type="text/html"/>
    <title>&#27005;&#22825;&#12486;&#12463;&#12494;&#12525;&#12472;&#12540;&#12459;&#12531;&#12501;&#12449;&#12524;&#12531;&#12473;2008&#12391;LT&#12375;&#12390;&#12365;&#12414;&#12375;&#12383;</title>
<content type="html">
            &lt;p&gt;2008/11/29に行われた &lt;a href=&quot;http://www.rakuten.co.jp/event/techconf/2008/session.html&quot;&gt;楽天テクノロジーカンファレンス2008&lt;/a&gt; (updated081216 リンク先更新)内で開催した &lt;a href=&quot;http://wiki.fdiary.net/rails/?RailsMeetingTokyo-0035&quot;&gt;Rails勉強会@東京第35回&lt;/a&gt; のLT大会で&lt;br /&gt;
Rails 2.2のi18nライブラリ、 &lt;a href=&quot;http://github.com/amatsuda/i18n_generators/&quot;&gt;i18n_generators&lt;/a&gt; についてLTしてきた。&lt;/p&gt;
&lt;p&gt;自分の資料作りに追われて皆さんの発表がじっくり聞けなかったのはちょっと残念だったかも。&lt;br /&gt;
それと、発表がトリだったので、そのまま会場にACアダプタを忘れて帰ってしまったのだが、ちゃんと楽天さんの技術部の中の人が保管してくださっていて、無事に手元に戻ってきた。楽天さんはいい会社です。生ビールも飲めるし。&lt;/p&gt;
&lt;p&gt;で、以下LTの資料。Rails 2.2の日本語化とかそこらへんのご興味のある方はご覧ください。というような内容でもないか。&lt;br /&gt;
&lt;div&gt;&lt;a href=&quot;http://www.slideshare.net/a_matsuda/i18ngenerators-presentation?type=powerpoint&quot; title=&quot;i18n_generatorsのご紹介&quot;&gt;i18n_generatorsのご紹介&lt;/a&gt;&lt;div&gt;View SlideShare &lt;a href=&quot;http://www.slideshare.net/a_matsuda/i18ngenerators-presentation?type=powerpoint&quot; title=&quot;View i18n_generatorsのご紹介 on SlideShare&quot;&gt;presentation&lt;/a&gt; or &lt;a href=&quot;http://www.slideshare.net/upload?type=powerpoint&quot;&gt;Upload&lt;/a&gt; your own. (tags: &lt;a href=&quot;http://slideshare.net/tag/rails勉強会-東京&quot;&gt;rails勉強会@東京&lt;/a&gt; &lt;a href=&quot;http://slideshare.net/tag/lt&quot;&gt;lt&lt;/a&gt;)&lt;/div&gt;&lt;/div&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.dio.jp/">
    <author>
      <name>Akira Matsuda</name>
    </author>
    <id>tag:blog.dio.jp,2008-11-22:65</id>
    <published>2008-11-22T01:32:00Z</published>
    <updated>2009-01-21T18:33:08Z</updated>
    <category term="EDGE"/>
    <category term="Rails"/>
    <link href="http://blog.dio.jp/2008/11/22/japanizing-rails-2-2-by-i18n-generators" rel="alternate" type="text/html"/>
    <title>Rails 2.2&#12398; I18n&#12395;&#12424;&#12427;&#26085;&#26412;&#35486;&#21270;&#12434;&#26368;&#12418;&#31777;&#21336;&#12395;&#34892;&#12358;&#26041;&#27861;</title>
<content type="html">
            &lt;p&gt;さて、Rails 2.2も &lt;a href=&quot;http://weblog.rubyonrails.org/2008/11/21/rails-2-2-i18n-http-validators-thread-safety-jruby-1-9-compatibility-docs&quot;&gt;無事にリリース&lt;/a&gt; されたわけだが、今回の目玉はなんといっても &#8220;I18n&#8221; 対応だろう。&lt;/p&gt;
&lt;p&gt;つまり、今回の大規模なI18n対応で、やっとこれが&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Rails 2.1.2 より抜粋&lt;/span&gt;
          options[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;object_name&lt;/span&gt;] &lt;span class=&quot;Keyword&quot;&gt;||=&lt;/span&gt; params.&lt;span class=&quot;Entity&quot;&gt;first&lt;/span&gt;
          options[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;header_message&lt;/span&gt;] &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;Entity&quot;&gt;pluralize&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;(&lt;/span&gt;count&lt;span class=&quot;StringEmbeddedSource&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;error&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; prohibited this &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;options&lt;span class=&quot;StringEmbeddedSource&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;&lt;span class=&quot;StringConstant&quot;&gt;:&lt;/span&gt;object_name&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Entity&quot;&gt;to_s&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Entity&quot;&gt;gsub&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;_&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; from being saved&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;unless&lt;/span&gt; options.&lt;span class=&quot;Entity&quot;&gt;include?&lt;/span&gt;(&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;header_message&lt;/span&gt;)
          options[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;message&lt;/span&gt;] &lt;span class=&quot;Keyword&quot;&gt;||=&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;There were problems with the following fields:&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;unless&lt;/span&gt; options.&lt;span class=&quot;Entity&quot;&gt;include?&lt;/span&gt;(&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;message&lt;/span&gt;)      
          error_messages &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; objects.&lt;span class=&quot;Entity&quot;&gt;sum&lt;/span&gt; {|&lt;span class=&quot;Variable&quot;&gt;object&lt;/span&gt;| object.&lt;span class=&quot;Entity&quot;&gt;errors&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;full_messages&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;map&lt;/span&gt; {|&lt;span class=&quot;Variable&quot;&gt;msg&lt;/span&gt;| &lt;span class=&quot;Entity&quot;&gt;content_tag&lt;/span&gt;(&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;li&lt;/span&gt;, msg) } }.join
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;こうなった、と。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Rails 2.2.2 より抜粋&lt;/span&gt;
          &lt;span class=&quot;Variable&quot;&gt;I18n&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;with_options&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;locale&lt;/span&gt; =&amp;gt; options[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;locale&lt;/span&gt;], &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;scope&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;activerecord&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;errors&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;template&lt;/span&gt;] &lt;span class=&quot;Keyword&quot;&gt;do &lt;/span&gt;|&lt;span class=&quot;Variable&quot;&gt;locale&lt;/span&gt;|
    (中略)
              locale.&lt;span class=&quot;Entity&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;header&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;count&lt;/span&gt; =&amp;gt; count, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;model&lt;/span&gt; =&amp;gt; object_name
            &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
    (後略)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;参考 : &lt;a href=&quot;http://wota.jp/ac/?date=20050802&quot;&gt;優しいRailsの育て方&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;そんなわけで、Rails 2.2からは従来のようにRailsのソースをごっそり置き換えたりするモンキーパッチのようなプラグインに頼らなくても、Rails自体の仕組みだけで日本語化(多言語化)が行えるようになった。&lt;/p&gt;
&lt;h2&gt;◆i18n_generators を使ってみる&lt;/h2&gt;
&lt;p&gt;さて、それではさっそく日本語化されたアプリを作ってみよう。&lt;br /&gt;
このあたり、まだ日本語の情報が全然少ないからよっぽど難しいのかと思われるかもしれないが、実はめちゃめちゃ簡単で、いくつかのコマンドを叩くだけであっさり実現できる。&lt;/p&gt;
&lt;p&gt;まずは、何も考えずに、 &lt;a href=&quot;http://rails-i18n.org/wiki/&quot;&gt;Rails I18n公式Wikiに載っている&lt;/a&gt; 、 &lt;a href=&quot;http://github.com/amatsuda/i18n_generators/&quot;&gt;i18n_generators&lt;/a&gt; という名前の魔法のgemをインストールしておく(名前の最後に &#8220;s&#8221; がつくのでご注意)。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; http://gems.github.comがgemのSOURCESに入ってない場合は以下を実行してから&lt;/span&gt;
% sudo gem so -a http://gems.github.com
&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; インストール&lt;/span&gt;
% sudo gem i amatsuda-i18n_generators
Successfully installed amatsuda-i18n_generators-0.2.0
1 gem installed
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;それから、Rails 2.2がインストールされている環境で、&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;% rails -v
Rails 2.2.2
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;アプリケーションを作成してcd。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;% rails i18n_test
      create  
      create  app/controllers
      create  app/helpers
      create  app/models
(略)
% cd i18n_test/
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;&lt;del&gt;config/environment.rbを編集してsqlite3を有効に(※ 2.2からデフォルトOFFに変わった？ハマる人続出だと思うんだけど・・・)&lt;/del&gt;&lt;/p&gt;
&lt;p&gt;じゃあまずはなんかscaffoldでもしてみよう。&lt;br /&gt;
以下のようにi18n_scaffoldジェネレーターを使うと、scaffoldがいい感じに他言語化されていたりする。 (081129 updated)&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;% ./script/generate i18n_scaffold user name:string

% rake db:migrate
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;日本語のリソースファイルを生成してくれる魔法のコマンドを叩いて(ロケール指定は &#8220;ja&#8221; で)、&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;% ./script/generate i18n ja
      exists  config/locales
      create  config/locales/ja.yml
      create  config/locales/models_ja.yml
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;あ、なんかUserモデルにバリデーションでも仕掛けとくか。&lt;br /&gt;
app/models/user.rb&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;JEntityNameType&quot;&gt;User&lt;span class=&quot;EntityInheritedClass&quot;&gt; &lt;span class=&quot;EntityInheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; ActiveRecord::Base&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;SupportFunction&quot;&gt;validates_presence_of&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;name&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;以上！！&lt;/p&gt;
&lt;p&gt;サーバーを起動して確認してみると、&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;% ./script/server
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;おおおー、ばっちり日本語化されてるー！！！&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;ということで、詳しくはあとで書く。&lt;/p&gt;
&lt;p&gt;とりあえず、このgem/pluginに関する質問、感想、フィードバックその他は大歓迎です。&lt;br /&gt;
あと、 &lt;a href=&quot;http://wiki.fdiary.net/rails/?RailsMeetingTokyo-0035&quot;&gt;『楽天テクノロジーカンファレンス２００８』&lt;/a&gt; というやつで、こいつについて何か話をすることになってるような気がします。&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.dio.jp/">
    <author>
      <name>Akira Matsuda</name>
    </author>
    <id>tag:blog.dio.jp,2008-11-22:64</id>
    <published>2008-11-22T00:12:00Z</published>
    <updated>2008-11-22T00:14:42Z</updated>
    <category term="EDGE"/>
    <category term="Rails"/>
    <link href="http://blog.dio.jp/2008/11/22/only-and-except-in-routes-for-rails22" rel="alternate" type="text/html"/>
    <title>Rails 2.2&#12391;routes&#12398;&#19981;&#35201;&#12394;resources&#12434;&#28040;&#12377;&#12395;&#12399;</title>
<content type="html">
            &lt;p&gt;ブログ再開。&lt;br /&gt;
さて、先日Rails 2.2系のmasterに以下の変更がコミットされた。&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://github.com/rails/rails/commit/44a3009ff068bf080de6764a8c884fbf0ceb920e&quot;&gt;http://github.com/rails/rails/commit/44a3009ff068bf080de6764a8c884fbf0ceb920e&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;そもそも今までのRailsの map.resourcesは、なんか routes.rbに1行書くだけで勝手にCRUD+αのroutesがうじゃうじゃ生成されて、邪魔くさいことこの上なかった。実際のアプリだと使われるURLの方が少ないぐらいなのに、rake routesの出力を無駄に汚されて不愉快きわまりない.&lt;/p&gt;
&lt;p&gt;というのを、そういえばちょうど前回の &lt;a href=&quot;http://wiki.fdiary.net/rails/?RailsMeetingTokyo-0034&quot;&gt;Rails勉強会@東京#34&lt;/a&gt; でも懸命に主張してみたりしたのだが、 &lt;strong&gt;REST信者&lt;/strong&gt; とかいう人たちには「気にするな」とか言われてまったく取り合ってもらえなくて悲しい思いをしたのだった。&lt;/p&gt;
&lt;p&gt;しかしみんなにどんなにREST教の教えを説かれても僕にはRailsのこの挙動だけは納得いってなかったんだが、こうなってみるとどうやら僕の感覚の方が正しかったってことですかね。&lt;/p&gt;
&lt;p&gt;ということで、以下実例。&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;リソースを作ってみたりする&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;% ./script/generate resource user

% ./script/generate resource group
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;ul&gt;
	&lt;li&gt;rake routesを表示してみたところ。ごにゃごにゃしてて見づらすぎる&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;% rake routes
              groups GET    /groups                          {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;index&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
    formatted_groups GET    /groups.:format                  {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;index&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                     POST   /groups                          {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;create&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                     POST   /groups.:format                  {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;create&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
           new_group GET    /groups/new                      {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;new&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
 formatted_new_group GET    /groups/new.:format              {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;new&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
          edit_group GET    /groups/:id/edit                 {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;edit&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
formatted_edit_group GET    /groups/:id/edit.:format         {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;edit&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
               group GET    /groups/:id                      {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;show&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
     formatted_group GET    /groups/:id.:format              {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;show&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                     PUT    /groups/:id                      {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;update&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                     PUT    /groups/:id.:format              {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;update&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                     DELETE /groups/:id                      {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;destroy&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                     DELETE /groups/:id.:format              {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;destroy&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
               users GET    /users                           {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;index&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
     formatted_users GET    /users.:format                   {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;index&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                     POST   /users                           {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;create&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                     POST   /users.:format                   {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;create&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
            new_user GET    /users/new                       {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;new&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
  formatted_new_user GET    /users/new.:format               {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;new&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
           edit_user GET    /users/:id/edit                  {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;edit&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
 formatted_edit_user GET    /users/:id/edit.:format          {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;edit&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                user GET    /users/:id                       {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;show&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
      formatted_user GET    /users/:id.:format               {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;show&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                     PUT    /users/:id                       {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;update&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                     PUT    /users/:id.:format               {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;update&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                     DELETE /users/:id                       {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;destroy&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                     DELETE /users/:id.:format               {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;destroy&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;ul&gt;
	&lt;li&gt;そこで、routes.rbに以下の条件を追記&lt;br /&gt;
% vi config/routes.rb&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; 引数は配列でも&lt;/span&gt;
  map.&lt;span class=&quot;Entity&quot;&gt;resources&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;groups&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;only&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;show&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;index&lt;/span&gt;]
&lt;span class=&quot;Comment&quot;&gt;  &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; シンボル一つでも配列でもOK&lt;/span&gt;
  map.&lt;span class=&quot;Entity&quot;&gt;resources&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;users&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;except&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;destroy&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;ul&gt;
	&lt;li&gt;routesがすっきりシンプルになった！&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;% rake routes
             groups GET  /groups                          {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;index&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
   formatted_groups GET  /groups.:format                  {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;index&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
              group GET  /groups/:id                      {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;show&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
    formatted_group GET  /groups/:id.:format              {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;groups&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;show&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
              users GET  /users                           {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;index&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
    formatted_users GET  /users.:format                   {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;index&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                    POST /users                           {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;create&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                    POST /users.:format                   {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;create&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
           new_user GET  /users/new                       {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;new&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
 formatted_new_user GET  /users/new.:format               {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;new&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
          edit_user GET  /users/:id/edit                  {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;edit&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
formatted_edit_user GET  /users/:id/edit.:format          {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;edit&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
               user GET  /users/:id                       {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;show&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
     formatted_user GET  /users/:id.:format               {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;show&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                    PUT  /users/:id                       {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;update&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
                    PUT  /users/:id.:format               {:controller=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, :action=&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;update&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;この機能は、ついさっきリリースされたRails 2.2から有効になっています。&lt;br /&gt;
明らかに良くなりましたね、こりゃ。これなら実案件でも使う気になってきた。&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.dio.jp/">
    <author>
      <name>Akira Matsuda</name>
    </author>
    <id>tag:blog.dio.jp,2008-09-08:60</id>
    <published>2008-09-08T13:49:00Z</published>
    <updated>2008-10-02T05:25:41Z</updated>
    <category term="EDGE"/>
    <category term="life"/>
    <category term="life"/>
    <link href="http://blog.dio.jp/2008/9/8/daughter-1-0-released" rel="alternate" type="text/html"/>
    <title>&#23064; 1.0 released!</title>
<content type="html">
            &lt;p&gt;2008年9月8日(聖母マリアが生まれた日だそうな)に、第1子が誕生した！！！&lt;br /&gt;
出生時の体重は2679g。思っていたよりもかなり小さい。&lt;br /&gt;
どれぐらい小さいかというと、これぐらい。&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;
   &lt;b&gt;&lt;em&gt;iPod Touch &amp;lt;=&amp;gt; 娘のあたま&lt;/em&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;出産には立ち会ってよかった。ほんとうに良かった。産まれた瞬間は今まで生きてきた中で一番感動した。&lt;br /&gt;
終電で家に帰って近所のスーパーで缶ビールを買って一人で祝杯をあげながら嬉しすぎて号泣しちゃってしばらく涙が止まんなくなるぐらい感動した。&lt;/p&gt;
&lt;p&gt;それから、ついったーで、IRCで、メッセで、メールで、MLで、ブログで、携帯で、携帯メールで、ショートメールで、電話で、手紙で、贈り物で、ごちそうで、飲み会で、ライヴのチケットで、現ナマで、それからもちろんリアルで、もう数えきれないぐらいのたくさんの方々にありとあらゆる手段であたたかい祝福のお言葉をいただいた。本当にありがたい。&lt;br /&gt;
現代は昔よりもコミュニケーションが希薄になってきたとかよく言われるけど、実は全然そんなことはなくて、コミュニケーションの手段が多様化されているぶんだけ、より多くの人とこんなにも色々な形でつながりが築かれているんだ、ということに、こういう節目のイベントがあるとふと気付かされる。思えばすごい時代になったものだ。&lt;/p&gt;
&lt;p&gt;そして我が娘はそんなすごい時代に産まれてきてしまったわけだ。僕らが子供だった頃から比べてもこの「1世代」でこんなにも世の中は進歩してしまった。&lt;br /&gt;
でもウチの娘はもっとすごい。彼女は、そんな世の中の30年の進歩に匹敵するぶん、おそらく生物としても進化している。&lt;br /&gt;
誰かさんが自らの姿に似せてヒトを創ったとか最初の人間は泥から生まれたとかみたいなおとぎ話を事実と混同していない限りは、現代人はある程度無条件にダーウィン科学を信仰するしかないわけで、つまりそうすると自分の娘は確実に僕ら自身の完全上位互換プロダクトだ、という事実を受け入れなければならない。&lt;br /&gt;
Windows NTに対する2000のように、Pentium IIに対するPentium IIIのように、僕ら旧世代モデルはどこをどう切っても自分の後継モデルには勝てない。そうでなければ、僕らは僕らの学んできた科学を裏切ることになってしまう。だから僕は自分の娘を、産まれてきた瞬間からめちゃめちゃ尊敬している。&lt;/p&gt;
&lt;p&gt;いま、僕の腕の中に、万物の霊長とも呼ばれる大いなるプロダクトの最新バージョンの小さな小さな1インスタンスが横たわっている。僕もこのプロジェクトに参加して31年目にして初めて小さなコミットを記すことができたことになる。そして、僕らがこの子に毎日ミルクをあげ続けるというこの行為は、人類の最もEdgeなリビジョンを、文字通り日々buildし続ける行為に他ならないのだ・・・&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.dio.jp/">
    <author>
      <name>Akira Matsuda</name>
    </author>
    <id>tag:blog.dio.jp,2008-08-03:47</id>
    <published>2008-08-03T19:02:00Z</published>
    <updated>2008-08-03T22:04:24Z</updated>
    <category term="Asakusa.rb"/>
    <category term="Rails"/>
    <category term="Ruby"/>
    <category term="events"/>
    <link href="http://blog.dio.jp/2008/8/3/2-asakusa-rb" rel="alternate" type="text/html"/>
    <title>&#31532;2&#22238;Asakusa.rb</title>
<content type="html">
            &lt;p&gt;7/26(土)、 第2回Asakusa.rbが開催された。&lt;/p&gt;
&lt;p&gt;今回は、 &lt;a href=&quot;http://sumidagawa-hanabi.com/&quot;&gt;隅田川花火大会&lt;/a&gt; の真っ最中に &lt;a href=&quot;http://rubyist.g.hatena.ne.jp/muscovyduck/&quot;&gt;花火会場のほど近くにお住まいのメンバー&lt;/a&gt; のご自宅にて開催、という、とっても夏の浅草「らしい」集いになった。&lt;br /&gt;
結局花火に夢中で、肝心のhackの方は全然はかどらなかったわけだが、まぁたまにはそういうのもアリなんじゃないでしょうかね。&lt;/p&gt;
&lt;p&gt;そんなわけで、 &lt;a href=&quot;http://qwik.jp/asakusarb/002_log.html&quot;&gt;まとめはこちら&lt;/a&gt; 。&lt;/p&gt;
&lt;p&gt;今回は、前回よりも一層、「Rubyの凄い人」と「Railsの濃い人」がそれぞれ集まったようなメンバーで、 &lt;a href=&quot;http://jp.rubyist.net/magazine/?0009-Hotlinks&quot;&gt;「RubygemsってやつをRuby 1.9から標準添付にしてるんだけどそんなもの使ったことないよ」っていう人&lt;/a&gt; と &lt;a href=&quot;http://wota.jp/ac/?date=20080726&quot;&gt;「Rubygemsは毎日使ってるけどRuby 1.9から標準添付になったなんて知らなかった」っていう人&lt;/a&gt; が異文化コミュニケーションを果たすことができたというのは、これもまたAsakusa.rbの活動のひとつの大きな狙いだったりするので、個人的にはけっこう満足だったりする。&lt;/p&gt;
&lt;p&gt;それから、今回のもうひとつ大きな収穫と言えば、「Rubyのおかしな挙動を見つけたらどんどん Redmineに上げちゃっていいよ」と Rubyコミッターチームに言っていただけたこと。&lt;br /&gt;
そんなわけで、とりあえず前回同様に最新版のRubyでも再現したSEGVの件について &lt;a href=&quot;http://redmine.ruby-lang.org/issues/show/369&quot;&gt;Redmineに報告しておいた&lt;/a&gt; 。&lt;/p&gt;
&lt;p&gt;今回のこれのおかげで、今後の進め方がひとつはっきり見えてきたような気はする。&lt;br /&gt;
つまり、日頃いろんな関わり方でRubyを使っている多彩なメンバーが集まって、あちこちからYARVを突っついていじめて、とにかくたくさんバグを出して、片っ端から Redmineに報告する、というだけでも、立派な成果と呼べるものになるんじゃないだろうか？&lt;br /&gt;
ただ、それにしてもこのチケットはあまりに大雑把すぎて非常にいただけないので、次からはもうちょっときちんと切り分けができるようになりたい、というあたりは課題かな。&lt;/p&gt;
&lt;p&gt;ちなみに、このとき明かされた舞波さんの新しいプラグインの構想が、超life changingで革命的すぎる一品だった！&lt;br /&gt;
あれさえあれば、Rails 2.xのあのダサかっこ悪い respond_toブロックがウルトラセクシーな記法に大変身！&lt;br /&gt;
心待ちにしておこう。&lt;/p&gt;
&lt;p&gt;と思っていたら来た！&lt;br /&gt;
&lt;a href=&quot;http://blog.s21g.com/articles/697&quot;&gt;http://blog.s21g.com/articles/697&lt;/a&gt;&lt;br /&gt;
・・・けど、 &lt;i&gt;致命的な問題&lt;/i&gt; が＞＜&lt;br /&gt;
ん〜、惜しい！&lt;/p&gt;
&lt;p&gt;ファンの皆様、引き続きmaiha先生の新作にご期待ください！&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.dio.jp/">
    <author>
      <name>Akira Matsuda</name>
    </author>
    <id>tag:blog.dio.jp,2008-07-27:44</id>
    <published>2008-07-27T05:50:00Z</published>
    <updated>2008-07-27T13:27:02Z</updated>
    <category term="EDGE"/>
    <category term="Rails"/>
    <category term="events"/>
    <link href="http://blog.dio.jp/2008/7/27/rails-2-2-i18n" rel="alternate" type="text/html"/>
    <title>Rails 2.2&#12398; I18n&#12395;&#12388;&#12356;&#12390;&#12367;&#12431;&#12375;&#12367;</title>
<content type="html">
            &lt;h2&gt;第31回Rails勉強会@東京のセッション「Rails 2.2の I18nについてくわしく」の資料&lt;/h2&gt;
&lt;h3&gt;●I18nモジュールとは&lt;/h3&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.fdiary.net/ml/rails/msg/2782&quot;&gt;ある日高橋会長のもとに舞い込んできたメール&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.artweb-design.de/2008/7/18/finally-ruby-on-rails-gets-internationalized&quot;&gt;2008年7月、Rails本体に取り込まれた&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://groups.google.com/group/rails-i18n&quot;&gt;Google groups&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://github.com/svenfuchs/i18n/tree/master&quot;&gt;Githubの I18nプロジェクト&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;ウォッチしてたら svenfuchsさんからメールが来た！&lt;/li&gt;
	&lt;li&gt;バージョンはまだ 0.0.1！&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;●ソース&lt;/h3&gt;
&lt;p&gt;github からこんな感じで検索してみる。&lt;br /&gt;
&lt;a href=&quot;http://github.com/rails/rails/search?q=i18n&amp;amp;choice=grep&quot;&gt;http://github.com/rails/rails/search?q=i18n&amp;amp;choice=grep&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;●重要そうなコミット&lt;/h3&gt;
&lt;ul&gt;
	&lt;li&gt;1発目&lt;br /&gt;
&lt;a href=&quot;http://github.com/rails/rails/commit/45d41f0dadd9fa171f306ff356770c4492726f30&quot;&gt;http://github.com/rails/rails/commit/45d41f0dadd9fa171f306ff356770c4492726f30&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;ActionMailerの他言語化？&lt;br /&gt;
&lt;a href=&quot;http://github.com/rails/rails/commit/6982acb0793fb6e59f52cab4062344a88e3691ce&quot;&gt;http://github.com/rails/rails/commit/6982acb0793fb6e59f52cab4062344a88e3691ce&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;I18n lib本体のコミット&lt;br /&gt;
&lt;a href=&quot;http://github.com/rails/rails/commit/fbe1823117c6170e26b328ce192a2fc0945af533&quot;&gt;http://github.com/rails/rails/commit/fbe1823117c6170e26b328ce192a2fc0945af533&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;いろいろマージ&lt;br /&gt;
&lt;a href=&quot;http://github.com/rails/rails/commit/636e6b7138864ceb1e309939cd879e710b287f3e&quot;&gt;http://github.com/rails/rails/commit/636e6b7138864ceb1e309939cd879e710b287f3e&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;●基本機能&lt;/h3&gt;
&lt;p&gt;I18nというライブラリのクラスメソッドがいくつか提供されている。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; [&lt;span class=&quot;Variable&quot;&gt;I18n&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;local_methods&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Object&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;methods&lt;/span&gt;]
=&amp;gt; [[&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;append_features&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;backend&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;backend=&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;default_exception_handler&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;default_locale&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;default_locale=&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;exception_handler=&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;l&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;locale&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;locale=&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;localize&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;normalize_translation_keys&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;populate&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;store_translations&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;t&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;translate&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;]]
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;デフォルトの localeは en-USになっている。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;I18n&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;locale&lt;/span&gt;
=&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;en-US&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;ja-JPに変更してみる。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;I18n&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;default_locale&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;ja-JP&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;詳しくはソースで。&lt;/p&gt;
&lt;h3&gt;●ソースの読みどころ&lt;/h3&gt;
&lt;ul&gt;
	&lt;li&gt;I18n gemの本体&lt;br /&gt;
activesupport/lib/active_support/vendor/i18n-0.0.1/  以下&lt;/li&gt;
	&lt;li&gt;基本的な操作とか&lt;br /&gt;
activesupport/lib/active_support/vendor/i18n-0.0.1/lib/i18n.rb&lt;/li&gt;
	&lt;li&gt;vendor/rails/activerecord/lib/active_record/validations.rb&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;●機能その1. translate&lt;/h3&gt;
&lt;p&gt;翻訳メソッド。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;I18n&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;hoge&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
=&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;translation missing: ja-JP, hoge&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;I18n&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;hoge&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;default&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;ほげ&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
=&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;ほげ&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;I18n&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;store_translations&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:'&lt;/span&gt;ja-JP&lt;span class=&quot;Constant&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;hoge&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;ホゲ&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
=&amp;gt; {&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;hoge&lt;/span&gt;=&amp;gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;ホゲ&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;I18n&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;hoge&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
=&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;ホゲ&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;I18n&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;hoge&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;default&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;ほげ&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
=&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;ホゲ&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;　&lt;/p&gt;
&lt;h3&gt;●機能その2. localize&lt;/h3&gt;
&lt;p&gt;日付や時刻、お金のフォーマット&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt; lv vendor&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;rails&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;activesupport&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;lib&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;active_support&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;locale&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;en&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Variable&quot;&gt;US&lt;/span&gt;.rb
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;　&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;I18n&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;backend&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;store_translations&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:'&lt;/span&gt;en-US&lt;span class=&quot;Constant&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, {
  &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;support&lt;/span&gt; =&amp;gt; {
    &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;array&lt;/span&gt; =&amp;gt; {
      &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;sentence_connector&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;and&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
    }
  },
  &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;date&lt;/span&gt; =&amp;gt; {
    &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;formats&lt;/span&gt; =&amp;gt; {
      &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;default&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;%Y-%m-%d&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
      &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;short&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;%b %d&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
      &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;long&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;%B %d, %Y&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
    },
    &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;day_names&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Support&quot;&gt;Date&lt;/span&gt;::&lt;span class=&quot;Entity&quot;&gt;DAYNAMES&lt;/span&gt;,
    &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;abbr_day_names&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Support&quot;&gt;Date&lt;/span&gt;::&lt;span class=&quot;Entity&quot;&gt;ABBR_DAYNAMES&lt;/span&gt;,
    &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;month_names&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Support&quot;&gt;Date&lt;/span&gt;::&lt;span class=&quot;Entity&quot;&gt;MONTHNAMES&lt;/span&gt;,
    &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;abbr_month_names&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Support&quot;&gt;Date&lt;/span&gt;::&lt;span class=&quot;Entity&quot;&gt;ABBR_MONTHNAMES&lt;/span&gt;,
    &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;order&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;year&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;month&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;day&lt;/span&gt;]
  },
  &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;time&lt;/span&gt; =&amp;gt; {
    &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;formats&lt;/span&gt; =&amp;gt; {
      &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;default&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;%a, %d %b %Y %H:%M:%S %z&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
      &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;short&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;%d %b %H:%M&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
      &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;long&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;%B %d, %Y %H:%M&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
    },
    &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;am&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;am&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,
    &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;pm&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;pm&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
  }
}
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;　&lt;/p&gt;
&lt;h3&gt;●サンプルアプリを作ってみる&lt;/h3&gt;
&lt;ul&gt;
	&lt;li&gt;ja-JP.rbという名前のファイルを $RAILS_ROOT/lib/locale/ に配置する。&lt;br /&gt;
自分で作るのはめんどくさいので gettext-railsからパチっちゃえ。&lt;br /&gt;
たぶんこんな感じで。&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;% cp vendor/rails/activerecord/lib/active_record/locale/en-US.rb lib/locale/

% cp /opt/local/lib/ruby/gems/1.8/gems/gettext-1.91.0/po/ja/rails.po lib/locale/

% fgrep &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;%{fn}&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt; rails.po &lt;span class=&quot;Keyword&quot;&gt;|&lt;/span&gt; ruby -e &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;puts STDIN.read.gsub(&amp;quot;msgid &amp;quot;, &amp;quot;s/&amp;quot;).gsub(&amp;quot;\nmsgstr &amp;quot;, &amp;quot;/&amp;quot;).gsub(/%\{fn\} ?/, &amp;quot;&amp;quot;).gsub(/$/, &amp;quot;/&amp;quot;)&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt; trans.sed

% sed -f trans.sed en-US.rb &lt;span class=&quot;Keyword&quot;&gt;|&lt;/span&gt; sed s/en-US/ja-JP/ &lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt; ja-JP.rb
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;ul&gt;
	&lt;li&gt;application_controller に以下の filterを設定&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;SupportFunction&quot;&gt;before_filter&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;set_locale&lt;/span&gt;
 
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;set_locale&lt;/span&gt;
    locale &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; params[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;locale&lt;/span&gt;] &lt;span class=&quot;Keyword&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;ja-JP&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;Variable&quot;&gt;I18n&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;locale&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; locale
    &lt;span class=&quot;Variable&quot;&gt;I18n&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;populate&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;do&lt;/span&gt;
      &lt;span class=&quot;Keyword&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;lib/locale/&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;locale&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;.rb&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;ul&gt;
	&lt;li&gt;つついて遊んでみる&lt;/li&gt;
&lt;/ul&gt;
          </content>  </entry>
  <entry xml:base="http://blog.dio.jp/">
    <author>
      <name>Akira Matsuda</name>
    </author>
    <id>tag:blog.dio.jp,2008-07-27:43</id>
    <published>2008-07-27T02:30:00Z</published>
    <updated>2008-07-27T02:32:12Z</updated>
    <category term="events"/>
    <link href="http://blog.dio.jp/2008/7/27/railstokyo-31-pojipe" rel="alternate" type="text/html"/>
    <title>Rails&#21193;&#24375;&#20250;@&#26481;&#20140;31&#12413;&#12376;&#12410;</title>
<content type="html">
            &lt;p&gt;　&lt;br /&gt;
　&lt;/p&gt;
&lt;h1&gt;&lt;a href=&quot;http://asakusa.rubyist.net&quot;&gt;Asakusa.rb&lt;/a&gt; をよろしく！&lt;/h1&gt;
&lt;p&gt;　&lt;br /&gt;
　&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.dio.jp/">
    <author>
      <name>Akira Matsuda</name>
    </author>
    <id>tag:blog.dio.jp,2008-07-25:29</id>
    <published>2008-07-25T05:46:00Z</published>
    <updated>2008-07-25T07:47:41Z</updated>
    <category term="EDGE"/>
    <category term="Rails"/>
    <category term="events"/>
    <link href="http://blog.dio.jp/2008/7/25/what-s-new-in-rails-2-1" rel="alternate" type="text/html"/>
    <title>Rails&#21193;&#24375;&#20250;@&#26481;&#20140;30 - what's new in Rails 2.1 &#12475;&#12483;&#12471;&#12519;&#12531;&#12414;&#12392;&#12417;</title>
<content type="html">
            &lt;p&gt;5月に行われた前回(第30回)Rails勉強会@東京では、ふりかえりの際に &lt;a href=&quot;http://wiki.fdiary.net/rails/?RailsMeetingTokyo-0030#l16&quot;&gt;『次回から「前回の勉強会のまとめ」を開催告知Wikiページに載っけるようにしてみよう』という Tryが挙げられていた&lt;/a&gt; ので、第30回の時にやった「what&#8217;s new in Rails 2.1 セッション」のまとめを。&lt;/p&gt;
&lt;p&gt;と言っても、2ヶ月も前のことを今更思い出せるわけないので、以前 &lt;a href=&quot;http://docs.google.com/Doc?docid=ddn3rmd_12ddzcw4q3&quot;&gt;GoogleDocsに揚げたやつ&lt;/a&gt; をそのまま貼るだけなんだけどね。&lt;br /&gt;
なので、以下の内容はあくまでも「2ヶ月前の最新情報」であり、現在の最新情報とは違うかもしれないのでご注意ください(以下こぴぺ)。&lt;br /&gt;
　&lt;/p&gt;
&lt;hr&gt;
&lt;h1&gt;what&#8217;s new in Rails 2.1 セッション&lt;/h1&gt;
&lt;p&gt;セッション中に即席で書いてるんでだいぶいい加減な内容です。すみません・・・&lt;/p&gt;
&lt;h2&gt;■ネタ元&lt;/h2&gt;
&lt;p&gt;Rails2.1について情報が載ってそうなところあれこれ。&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Ryan&#8217;s Scraps&lt;br /&gt;
&lt;a href=&quot;http://ryandaigle.com/tags/Edge%20Rails&quot;&gt;http://ryandaigle.com/tags/Edge%20Rails&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;redemption in a blog&lt;br /&gt;
&lt;a href=&quot;http://blog.codefront.net/category/ruby-on-rails/&quot;&gt;http://blog.codefront.net/category/ruby-on-rails/&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;GitHub&lt;br /&gt;
&lt;a href=&quot;http://github.com/rails&quot;&gt;http://github.com/rails&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;Lighthouse&lt;br /&gt;
&lt;a href=&quot;http://rails.lighthouseapp.com/dashboard&quot;&gt;http://rails.lighthouseapp.com/dashboard&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;Trac&lt;br /&gt;
新しいバグは全て Lighthouseに登録されるようになっているが、&lt;br /&gt;
旧バグの中にはまだこちらで生き残っているものもあり。&lt;br /&gt;
&lt;a href=&quot;http://dev.rubyonrails.org/&quot;&gt;http://dev.rubyonrails.org/&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;Riding Rails&lt;br /&gt;
A taste of what&#8217;s coming in Rails 2.1&lt;br /&gt;
&lt;a href=&quot;http://weblog.rubyonrails.org/2008/4/1/a-taste-of-what-s-coming-in-rails-2-1&quot;&gt;http://weblog.rubyonrails.org/2008/4/1/a-taste-of-what-s-coming-in-rails-2-1&lt;/a&gt;&lt;br /&gt;
2.1 RC1 リリース告知&lt;br /&gt;
&lt;a href=&quot;http://weblog.rubyonrails.org/2008/4/30/rails-2-1-release-candidate-is-imminent&quot;&gt;http://weblog.rubyonrails.org/2008/4/30/rails-2-1-release-candidate-is-imminent&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;Ruby on Rails: Core&lt;br /&gt;
&lt;a href=&quot;http://groups.google.co.jp/group/rubyonrails-core&quot;&gt;http://groups.google.co.jp/group/rubyonrails-core&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;Rails Envy&lt;br /&gt;
&lt;a href=&quot;http://railsenvy.com/&quot;&gt;http://railsenvy.com/&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;Railscasts&lt;br /&gt;
&lt;a href=&quot;http://railscasts.com/&quot;&gt;http://railscasts.com/&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;松田ぽじぺ@Rails東京29&lt;br /&gt;
&lt;a href=&quot;http://docs.google.com/Doc?id=ddn3rmd_11gx4t2cjg&quot;&gt;http://docs.google.com/Doc?id=ddn3rmd_11gx4t2cjg&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;松田ぽじぺ@Rails東京30&lt;br /&gt;
&lt;a href=&quot;http://docs.google.com/Doc?id=ddn3rmd_12ddzcw4q3&quot;&gt;http://docs.google.com/Doc?id=ddn3rmd_12ddzcw4q3&lt;/a&gt;&lt;br /&gt;
　&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;■Rails Edgeを cloneしてみよう&lt;/h2&gt;
&lt;p&gt;今のところ、Rails 2.1系を触ってみるには、以下のような方法がある。&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;RC1を使う&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;% rake rails:freeze:edge
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;zipで固められた最新ソースの玉を落として解凍してくれるように変更されたらしい&lt;br /&gt;
(たぶん Gitがまだ充分に普及していないから(?))。&lt;br /&gt;
が、zipファイルを上げる運用はまだ運用が開始されていない模様。&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;piston&lt;br /&gt;
pistonが Gitに対応してくれたらこれが一番ラクかも。&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;gitコマンドで&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;% rails edge_080518
% cd edge_080518/rails
% git clone git://github.com/rails/rails.git
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;　&lt;/p&gt;
&lt;h2&gt;■Rails2.1の新機能たち&lt;/h2&gt;
&lt;p&gt;主立ったものを列挙してみます。これまた当日に思い出しベースで書いているので網羅はできてない気がしますが。&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;named_scope&lt;br /&gt;
昨秋登場した has_finder という life changingなプラグインが本家に取り込まれた。&lt;br /&gt;
個人的には、おそらくこれが Rails2.1の最大のウリなんじゃないかと(詳しくは後述)。&lt;br /&gt;
&lt;a href=&quot;http://ryandaigle.com/articles/2008/3/24/what-s-new-in-edge-rails-has-finder-functionality&quot;&gt;http://ryandaigle.com/articles/2008/3/24/what-s-new-in-edge-rails-has-finder-functionality&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://pivots.pivotallabs.com/users/nick/blog/articles/284-hasfinder-it-s-now-easier-than-ever-to-create-complex-re-usable-sql-queries&quot;&gt;http://pivots.pivotallabs.com/users/nick/blog/articles/284-hasfinder-it-s-now-easier-than-ever-to-create-complex-re-usable-sql-queries&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;has_one :through&lt;br /&gt;
関連テーブルを挟んだ has_one 関連がエレガントに書ける機能。&lt;br /&gt;
&lt;a href=&quot;http://ryandaigle.com/articles/2008/3/24/what-s-new-in-edge-rails-has-one-through&quot;&gt;http://ryandaigle.com/articles/2008/3/24/what-s-new-in-edge-rails-has-one-through&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;ARのレコードに dirty object機能&lt;/li&gt;
&lt;/ul&gt;カラム名 + _changed? メソッドが例によって各 content_columnsに追加される ARマジック。&lt;p&gt;save時に発行される update文を、変更されたカラムのみを対象にすることができて、うまく使えばパフォーマンスの向上が見込まれる。&lt;br /&gt;
さらに、変更前のオリジナルの値も保持してくれている。&lt;br /&gt;
&lt;span class=&quot;caps&quot;&gt;ADO&lt;/span&gt; .Netの DataTableにあったようなあの機能という理解で良いかと。&lt;br /&gt;
&lt;a href=&quot;http://ryandaigle.com/articles/2008/3/31/what-s-new-in-edge-rails-dirty-objects&quot;&gt;http://ryandaigle.com/articles/2008/3/31/what-s-new-in-edge-rails-dirty-objects&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://dev.rubyonrails.org/changeset/9157&quot;&gt;http://dev.rubyonrails.org/changeset/9157&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://blog.codefront.net/2008/04/05/living-on-the-edge-of-rails-14-the-extreme-edition-extremely-late/&quot;&gt;http://blog.codefront.net/2008/04/05/living-on-the-edge-of-rails-14-the-extreme-edition-extremely-late/&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-partial-updates&quot;&gt;http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-partial-updates&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;AR#create にブロックを渡せるように&lt;br /&gt;
ブロック内部を returning的に書ける文法が追加された。見た目がRubyっぽく書けて嬉しいかも？&lt;br /&gt;
&lt;a href=&quot;http://github.com/rails/rails/commit/dd120ede53eaf71dee76894998a81626b7a689fc&quot;&gt;http://github.com/rails/rails/commit/dd120ede53eaf71dee76894998a81626b7a689fc&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;migrationファイルのファイル名が連番じゃなくてタイムスタンプに&lt;br /&gt;
&lt;a href=&quot;http://ryandaigle.com/articles/2008/4/2/what-s-new-in-edge-rails-utc-based-migration-versioning&quot;&gt;http://ryandaigle.com/articles/2008/4/2/what-s-new-in-edge-rails-utc-based-migration-versioning&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;schema_infoテーブル &#8594; schema_migrations という新テーブル&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;Railsプロジェクトに依存している gemを設定できるように&lt;br /&gt;
&lt;a href=&quot;http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies&quot;&gt;http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;RAILS_ROOT &#8594; Rails.root, RAILS_ENV &#8594; Rails.env&lt;br /&gt;
&lt;a href=&quot;http://dev.rubyonrails.org/changeset/9180&quot;&gt;http://dev.rubyonrails.org/changeset/9180&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;ActiveModel&lt;br /&gt;
2.1には正式に入るのかも？&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;TimeZone機能&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;rake &lt;span class=&quot;SupportFunction&quot;&gt;time&lt;/span&gt;:zones:*
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;&#8594; 非US系開発者から若干反感を買ってる模様(以下のコメント欄など参照)。&lt;br /&gt;
&lt;a href=&quot;http://rails.lighthouseapp.com/projects/8994/tickets/195-convenience-methods-for-time-zones-outside-the-u-s&quot;&gt;http://rails.lighthouseapp.com/projects/8994/tickets/195-convenience-methods-for-time-zones-outside-the-u-s&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;javascript_include_tag とかの :defaults を自分で再定義できるように&lt;br /&gt;
&lt;a href=&quot;http://blog.codefront.net/2008/03/20/living-on-the-edge-of-rails-12/&quot;&gt;http://blog.codefront.net/2008/03/20/living-on-the-edge-of-rails-12/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;ドキュメントがすごい勢いで充実中&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;Ruby1.9 / 1.8.7 対応&lt;br /&gt;
実はこれが一番嬉しい変更、という人も多いかも。&lt;br /&gt;
1.9系のメソッドたちは ActiveSupportと激しくかぶるので、ActiveSupportにかなり修正が入っている。&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;インフラの変化&lt;br /&gt;
Subversion &#8594; Git&lt;br /&gt;
Trac &#8594; Github&lt;br /&gt;
Trac &#8594; Lighthouse&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;script/plugin install が Gitのリポジトリに対応&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;script/dbconsole&lt;br /&gt;
上記のとおり。&lt;br /&gt;
&lt;a href=&quot;http://github.com/rails/rails/commit/4a07103687084496b773e18a03b1f2f5e686f7ad&quot;&gt;http://github.com/rails/rails/commit/4a07103687084496b773e18a03b1f2f5e686f7ad&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;(※懇親会で喋ってて思い出したので追記)&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;ARで connection pool の実装が開始&lt;br /&gt;
&lt;a href=&quot;http://groups.google.co.jp/group/rubyonrails-core/browse_thread/thread/16851dd787844a34/e89e9c741f89227e&quot;&gt;http://groups.google.co.jp/group/rubyonrails-core/browse_thread/thread/16851dd787844a34/e89e9c741f89227e&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;■ named_scopeを詳しく&lt;/h2&gt;
&lt;p&gt;以下、セッション中にデモで書いたコード +α をいちおう載っけておきます。&lt;br /&gt;
もう終わった勉強会のぽじぺを見る人って居るんかな？とは思いつつ・・・&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Railsアプリを生成して Edge Railsを取得&lt;br /&gt;
手順は上記のとおり。&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;こんな感じのいいかげんな modelを一丁 generate&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;% ./script/generate model person name:string age:integer gender:integer
% rake db:migrate
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;ul&gt;
	&lt;li&gt;サンプルデータを何件か作って、&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;create&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;name&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;person 1&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;age&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Constant&quot;&gt;20&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;gender&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;

    &lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;create&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;do &lt;/span&gt;|&lt;span class=&quot;Variable&quot;&gt;p&lt;/span&gt;|
    &lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;   p.&lt;span class=&quot;Entity&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;person 2&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;   p.&lt;span class=&quot;Entity&quot;&gt;age&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;30&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;   p.&lt;span class=&quot;Entity&quot;&gt;gender&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;

    &lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;create&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;name&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;person 3&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;age&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Constant&quot;&gt;3&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;gender&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;ul&gt;
	&lt;li&gt;named_scopeをあれこれ作ってみる&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;JEntityNameType&quot;&gt;Person&lt;span class=&quot;EntityInheritedClass&quot;&gt; &lt;span class=&quot;EntityInheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; ActiveRecord::Base&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;      &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Hashで conditions。基本形。&lt;/span&gt;
      named_scope &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;male&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;conditions&lt;/span&gt; =&amp;gt; {&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;gender&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;}
      named_scope &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;female&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;conditions&lt;/span&gt; =&amp;gt; {&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;gender&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt;}
&lt;span class=&quot;Comment&quot;&gt;      &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Stringで conditions。&lt;/span&gt;
      named_scope &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;adult&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;conditions&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;age &amp;gt;= 20&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;      &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Procで scopeを定義した形。例がへぼくてすいません。&lt;/span&gt;
      named_scope &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;name_start_with_p&lt;/span&gt;, lambda { {&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;conditions&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;name like ?&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;p%&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;]} }
&lt;span class=&quot;Comment&quot;&gt;      &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Proc方式だと scopeに引数も渡せる。&lt;/span&gt;
      named_scope &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;older_than&lt;/span&gt;, lambda {|&lt;span class=&quot;Variable&quot;&gt;n&lt;/span&gt;| {&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;conditions&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;age &amp;gt;= ?&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, n]} }
&lt;span class=&quot;Comment&quot;&gt;      &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; さっきのへぼい例もこれなら実用的。&lt;/span&gt;
      named_scope &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;name_start_with&lt;/span&gt;, lambda {|&lt;span class=&quot;Variable&quot;&gt;s&lt;/span&gt;| {&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;conditions&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;name like ?&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;s&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;%&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;]} }
    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;ul&gt;
	&lt;li&gt;作ったnamed_scopeたちをつついて遊んでみる&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;male&lt;/span&gt;
  &lt;span class=&quot;Variable&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Load&lt;/span&gt; (&lt;span class=&quot;Constant&quot;&gt;0.000603&lt;/span&gt;)   &lt;span class=&quot;Variable&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;people&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;WHERE&lt;/span&gt; (&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;people&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;.&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;gender&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;)
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;adult&lt;/span&gt;
  &lt;span class=&quot;Variable&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Load&lt;/span&gt; (&lt;span class=&quot;Constant&quot;&gt;0.000596&lt;/span&gt;)   &lt;span class=&quot;Variable&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;people&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;WHERE&lt;/span&gt; (age &lt;span class=&quot;Keyword&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;20&lt;/span&gt;)
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;older_than&lt;/span&gt;(&lt;span class=&quot;Constant&quot;&gt;7&lt;/span&gt;)
  &lt;span class=&quot;Variable&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Load&lt;/span&gt; (&lt;span class=&quot;Constant&quot;&gt;0.000651&lt;/span&gt;)   &lt;span class=&quot;Variable&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;people&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;WHERE&lt;/span&gt; (age &lt;span class=&quot;Keyword&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;7&lt;/span&gt;)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;動いた。あれ？genderは予約語だったか？とか思いつつ。&lt;br /&gt;
こんな調子で、ちっちゃいクエリの断片をあらかじめ名前を付けて定義しておくことができる、というのが named_scope の基本機能。&lt;br /&gt;
これだけだと、昔 Javaが流行ってた頃に &lt;span class=&quot;caps&quot;&gt;DAO&lt;/span&gt; って言われてたやつと何が違うの？と言われてしまいそうなところだが、&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;なんと、ネストして呼び出した時のSQLの発行は一回だけ！&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;female&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;adult&lt;/span&gt;
      &lt;span class=&quot;Variable&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Load&lt;/span&gt; (&lt;span class=&quot;Constant&quot;&gt;0.000494&lt;/span&gt;)   &lt;span class=&quot;Variable&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;people&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;WHERE&lt;/span&gt; ((age &lt;span class=&quot;Keyword&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;20&lt;/span&gt;) &lt;span class=&quot;Variable&quot;&gt;AND&lt;/span&gt; (&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;people&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;.&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;gender&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt;))
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;とにかくこれがすごい。呼び出し側のコードの可読性がめちゃめちゃ高くてシビれる。&lt;br /&gt;
 &#8594; 流れるようなインターフェース(笑)&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;そういえばセッションでは説明し忘れたけど、countとか書いても勝手にネストしてくれるよ。&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;older_than&lt;/span&gt;(&lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;).&lt;span class=&quot;Entity&quot;&gt;female&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;name_start_with&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;松&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).&lt;span class=&quot;Entity&quot;&gt;count&lt;/span&gt;
  &lt;span class=&quot;Variable&quot;&gt;SQL&lt;/span&gt; (&lt;span class=&quot;Constant&quot;&gt;0.000375&lt;/span&gt;)   &lt;span class=&quot;Variable&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;count&lt;/span&gt;(&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt;) &lt;span class=&quot;Variable&quot;&gt;AS&lt;/span&gt; count_all &lt;span class=&quot;Variable&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;people&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;WHERE&lt;/span&gt; (((name like &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;松%&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;) &lt;span class=&quot;Variable&quot;&gt;AND&lt;/span&gt; (&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;people&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;.&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;gender&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt;)) &lt;span class=&quot;Variable&quot;&gt;AND&lt;/span&gt; (age &lt;span class=&quot;Keyword&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;))
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;join とか sortとか、その他もろもろは今回は省略。&lt;br /&gt;
ちなみに、実はそのあたりは今でも盛んにコミットが行われているところなので、仕様もまだ多少揺れる可能性があるかも。&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;named_scopeメソッドで作られるものたちの実体は？&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; pp &lt;span class=&quot;Support&quot;&gt;Person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;scopes&lt;/span&gt;
{&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;male&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&amp;lt;Proc:0x017ead50@/Users/matsuda/railstokyo/edge080518/vendor/rails/activerecord/lib/active_record/named_scope.rb:87&amp;gt;,&lt;/span&gt;
 &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;name_start_with&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&amp;lt;Proc:0x017ead50@/Users/matsuda/railstokyo/edge080518/vendor/rails/activerecord/lib/active_record/named_scope.rb:87&amp;gt;,&lt;/span&gt;
 &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;female&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&amp;lt;Proc:0x017ead50@/Users/matsuda/railstokyo/edge080518/vendor/rails/activerecord/lib/active_record/named_scope.rb:87&amp;gt;,&lt;/span&gt;
 &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;adult&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&amp;lt;Proc:0x017ead50@/Users/matsuda/railstokyo/edge080518/vendor/rails/activerecord/lib/active_record/named_scope.rb:87&amp;gt;,&lt;/span&gt;
 &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;name_start_with_p&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&amp;lt;Proc:0x017ead50@/Users/matsuda/railstokyo/edge080518/vendor/rails/activerecord/lib/active_record/named_scope.rb:87&amp;gt;,&lt;/span&gt;
 &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;scoped&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&amp;lt;Proc:0x017ead50@/Users/matsuda/railstokyo/edge080518/vendor/rails/activerecord/lib/active_record/named_scope.rb:87&amp;gt;,&lt;/span&gt;
 &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;older_than&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&amp;lt;Proc:0x017ead50@/Users/matsuda/railstokyo/edge080518/vendor/rails/activerecord/lib/active_record/named_scope.rb:87&amp;gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;こんな感じの、キー = 宣言した名前、値 = Proc のインスタンス、な Hash で保持されていることがわかる。&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;これを踏まえて、よくある検索画面を想定して動的にクエリを組み立ててみる&lt;br /&gt;
さて、この named_scope機能が実際のアプリでどう使えるか、って考えてみると、&lt;br /&gt;
よくある検索画面みたいなやつで条件に含める項目自体が動的に変化するようなケースを&lt;br /&gt;
思いつくんじゃないだろうか。&lt;br /&gt;
つまり、どの scopeをクエリに組み込むか、というのを動的に選んでいきながら複雑なクエリを組み立てて、&lt;br /&gt;
最後に一発ドーンと実行するようなイメージ。&lt;/li&gt;
&lt;/ul&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;self.search&lt;/span&gt;(&lt;span class=&quot;Variable&quot;&gt;params&lt;/span&gt;)
  exec_scopes &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; []
  &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; params[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;is_male&lt;/span&gt;]
    exec_scopes &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; [&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;male&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;nil&lt;/span&gt;]
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; params[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;age_min&lt;/span&gt;]
    exec_scopes &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; [&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;older_than&lt;/span&gt;, params[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;age_min&lt;/span&gt;]]
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; (中略)&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;h4&gt;おまけ&lt;/h4&gt;
&lt;p&gt;セッションでは上記のように書いて、こんな感じで実行したい scopeを配列とかに溜めて&lt;br /&gt;
evalか injectぐらいでガツッと実行してやるしかないよねー、みたいな説明をしておいたが、&lt;br /&gt;
Yuumiさんから「かなりぐちゃぐちゃなコードになりそう」&lt;br /&gt;
というようなご意見を頂いた。うーん。そうなんですよねー。&lt;/p&gt;
&lt;p&gt;さて、そこらへんはその場でコードは書ききっていなかったので、以下参考までに実装イメージを。&lt;/p&gt;
&lt;h4&gt;※ 実装案1&lt;/h4&gt;
&lt;p&gt;つまりこういう文字列を組み立てて、&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;exec_scopes_string &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; exec_scopes.&lt;span class=&quot;Entity&quot;&gt;map&lt;/span&gt; {|&lt;span class=&quot;Variable&quot;&gt;s&lt;/span&gt;| &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;s&lt;span class=&quot;StringEmbeddedSource&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;(&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;s&lt;span class=&quot;StringEmbeddedSource&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;)&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}.&lt;span class=&quot;Entity&quot;&gt;join&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;.&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;evalに食わせるという。&lt;br /&gt;
引数の型とか数とかまともにハンドリングしてないけどまぁ大体こんな流れで。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;eval &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Person.&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;exec_scopes_string&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;h4&gt;※ 実装案2&lt;/h4&gt;
&lt;p&gt;injectでぐりぐり実行させる。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;exec_scopes.&lt;span class=&quot;Entity&quot;&gt;inject&lt;/span&gt;(&lt;span class=&quot;Variable&quot;&gt;Person&lt;/span&gt;) {|&lt;span class=&quot;Variable&quot;&gt;p&lt;/span&gt;, &lt;span class=&quot;Variable&quot;&gt;s&lt;/span&gt;| scopes[s[&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;]].&lt;span class=&quot;Entity&quot;&gt;call&lt;/span&gt; p, &lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt;s[&lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;]}
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;やっぱりこっちのほうがイケてそうかなぁ。&lt;/p&gt;
&lt;p&gt;ということで、案2のほうで実装してみたサンプルがこちら。&lt;br /&gt;
引数を複数取る scopeにも対応したかったので、例としてこんな scopeを追加して、&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; 複数の引数。&lt;/span&gt;
    named_scope &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;age_between&lt;/span&gt;, lambda {|&lt;span class=&quot;Variable&quot;&gt;from&lt;/span&gt;, &lt;span class=&quot;Variable&quot;&gt;to&lt;/span&gt;| {&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;conditions&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;age between ? and ?&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, from, to]} }
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;検索を実行するメソッドをこんなふうに。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;self.search&lt;/span&gt;(&lt;span class=&quot;Variable&quot;&gt;params&lt;/span&gt;)
      exec_scopes &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; []  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; [実行するスコープ, [引数の配列]] な配列&lt;/span&gt;
      exec_scopes &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; [&lt;span class=&quot;Support&quot;&gt;Person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;scopes&lt;/span&gt;[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;male&lt;/span&gt;], &lt;span class=&quot;Constant&quot;&gt;nil&lt;/span&gt;] &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; params[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;is_male&lt;/span&gt;]
      exec_scopes &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; [&lt;span class=&quot;Support&quot;&gt;Person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;scopes&lt;/span&gt;[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;older_than&lt;/span&gt;], params[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;age_min&lt;/span&gt;]] &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; params[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;age_min&lt;/span&gt;]
      exec_scopes &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; [&lt;span class=&quot;Support&quot;&gt;Person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;scopes&lt;/span&gt;[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;age_between&lt;/span&gt;], [params[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;age_between&lt;/span&gt;][&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;], params[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;age_between&lt;/span&gt;][&lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;]]] &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; params[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;age_between&lt;/span&gt;]
&lt;span class=&quot;Comment&quot;&gt;      &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; あとは、こんな調子で他の paramsたちの解釈をずらずらと書く。ここでは省略。&lt;/span&gt;

&lt;span class=&quot;Comment&quot;&gt;      &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; これが呼び出し部&lt;/span&gt;
      exec_scopes.&lt;span class=&quot;Entity&quot;&gt;reverse&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;inject&lt;/span&gt;(&lt;span class=&quot;Variable&quot;&gt;Person&lt;/span&gt;) {|&lt;span class=&quot;Variable&quot;&gt;p&lt;/span&gt;, &lt;span class=&quot;Variable&quot;&gt;s&lt;/span&gt;| s[&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;].&lt;span class=&quot;Entity&quot;&gt;call&lt;/span&gt; p, &lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt;s[&lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;]}.&lt;span class=&quot;Entity&quot;&gt;all&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;実行結果はこちら。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;search&lt;/span&gt;({&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;is_male&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Constant&quot;&gt;true&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;age_between&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;30&lt;/span&gt;]})
      &lt;span class=&quot;Variable&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Load&lt;/span&gt; (&lt;span class=&quot;Constant&quot;&gt;0.000518&lt;/span&gt;)   &lt;span class=&quot;Variable&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;people&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;WHERE&lt;/span&gt; ((&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;people&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;.&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;gender&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;) &lt;span class=&quot;Variable&quot;&gt;AND&lt;/span&gt; (age between &lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;30&lt;/span&gt;))
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;ということで、とりあえずめでたく動作。&lt;/p&gt;
&lt;p&gt;けっこうスッキリ書けたと思うが、でもこれは確かに書いた本人にしかわからないコードかも・・・&lt;br /&gt;
ポイントは便利メソッド injectの()内引数の使いかたと、最後にさりげなく書かれた .all(scopeが1個も使われなかった場合のデフォルトscopeになる)の工夫。&lt;br /&gt;
やっぱり Rubyはこんな書き方ができちゃうから面白い。&lt;br /&gt;
ただ、このあたりは需要がありそうなので、きっとフレームワークがもうちょっと親切な仕組みを提供してくれることでしょう。&lt;/p&gt;
* セッション後、もろはしさんが言ってた「これって集合のイメージだよね」みたいな説明のしかたが一番わかりやすいかもですね。
          </content>  </entry>
  <entry xml:base="http://blog.dio.jp/">
    <author>
      <name>Akira Matsuda</name>
    </author>
    <id>tag:blog.dio.jp,2008-07-24:41</id>
    <published>2008-07-24T00:01:00Z</published>
    <updated>2008-07-24T10:19:30Z</updated>
    <category term="EDGE"/>
    <category term="Rails"/>
    <link href="http://blog.dio.jp/2008/7/24/loading-fixtures-with-arbitrary-filename-and-directory" rel="alternate" type="text/html"/>
    <title>&#20219;&#24847;&#12398;&#12501;&#12449;&#12452;&#12523;&#21517;&#12392;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#21517;&#12398; fixtures&#12364;&#35501;&#12415;&#36796;&#12417;&#12427;&#12424;&#12358;&#12395;&#12394;&#12387;&#12383;</title>
<content type="html">
            &lt;p&gt;Railsの fixturesはたいへん便利な仕組みなのだが、今までは決められた名前のディレクトリ($RAILS_ROOT/test/fixtures/)内の決められた名前(テーブル名と同じ名前)のファイルしか読み込めないという制約があったため、例えば複数パターンのテストデータを用意しおいて切り替えて DBに食わせたいような場合なんかに、ちょっと不便に感じることがあった。&lt;br /&gt;
が、最近の edgeでは2箇所ほど fixtures関連の修正が入っており、fixturesの使い勝手が向上している。&lt;br /&gt;
　&lt;/p&gt;
&lt;h3&gt;1. サブディレクトリ内の fixturesを読み込む rakeタスク&lt;/h3&gt;
&lt;p&gt;まず、fixturesをディレクトリで分けて複数用意してディレクトリ名を指定して読み込む rakeタスクが &lt;a href=&quot;http://github.com/rails/rails/commit/697ee1a50dea7580a7240535d3ad89d2d090721a&quot;&gt;実装された&lt;/a&gt; 。&lt;/p&gt;
&lt;p&gt;例えばこんな fixturesファイルを用意して、&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;i&gt;test/fixtures/users.yml&lt;/i&gt;&lt;/strong&gt;&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;MetaTagAll&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;john&lt;/span&gt;&lt;span class=&quot;MetaTagAll&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;name&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;John&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;MetaTagAll&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;paul&lt;/span&gt;&lt;span class=&quot;MetaTagAll&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;name&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;Paul&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;ふつうに rakeタスクで loadすると、&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;$ rake db:fixtures:load
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;DBの中身はこうなる。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;$ ./script/runner &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;p User.all.map(&amp;amp;:name)&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
[&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Paul&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;John&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;]
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;　&lt;br /&gt;
と、ここまでは従来どおりだが、さらに Rails 2.2では、こんなディレクトリを用意して、&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;$ mkdir test/fixtures/ja
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;こんな fixturesファイルを作ったら、&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;i&gt;test/fixtures/ja/users.yml&lt;/i&gt;&lt;/strong&gt;&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;MetaTagAll&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;taro&lt;/span&gt;&lt;span class=&quot;MetaTagAll&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;MetaTagAll&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;MetaTagAll&quot;&gt;:&lt;/span&gt; &lt;/span&gt;太郎

&lt;span class=&quot;MetaTagAll&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;hanako&lt;/span&gt;&lt;span class=&quot;MetaTagAll&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;MetaTagAll&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;MetaTagAll&quot;&gt;:&lt;/span&gt; &lt;/span&gt;花子
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;こんなコマンドで loadできるようになった。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;$ rake db:fixtures:load FIXTURES_DIR=ja
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;結果はこのとおり。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;$ ./script/runner &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;p User.all.map(&amp;amp;:name)&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
[&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;花子&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;太郎&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;]
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;　&lt;/p&gt;
&lt;h3&gt;2. fixturesメソッドでテーブル名と同じ名前以外の任意のファイルを読み込めるようになった&lt;/h3&gt;
&lt;p&gt;こちらの件は、折しも RubyKaigi 2008の会場で Rails勉強会@東京ブースのよろず質問コーナーで質問を頂いた内容だったりする。&lt;br /&gt;
Rails 2.2では &lt;a href=&quot;http://github.com/rails/rails/commit/d72c66532f959846cdc2d7fb1dc1ef6ba87bdcb1&quot;&gt;このパッチのコミットのおかげで&lt;/a&gt; バッチリ解決できそうになったので、いまさらここで遅レスな回答を。&lt;/p&gt;
&lt;p&gt;例えば今度はこんな fixturesファイルを読み込ませたい場合、&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;i&gt;test/fixtures/elp.yml&lt;/i&gt;&lt;/strong&gt;&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;MetaTagAll&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;keith&lt;/span&gt;&lt;span class=&quot;MetaTagAll&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;name&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;Keith&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;MetaTagAll&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;greg&lt;/span&gt;&lt;span class=&quot;MetaTagAll&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;name&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;Greg&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;MetaTagAll&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;carl&lt;/span&gt;&lt;span class=&quot;MetaTagAll&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;name&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;Carl&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;テストケースではこんなふうに書けばOKになった。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;i&gt;test/unit/user_test.rb&lt;/i&gt;&lt;/strong&gt;&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;test_helper&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;JEntityNameType&quot;&gt;UserTest&lt;span class=&quot;EntityInheritedClass&quot;&gt; &lt;span class=&quot;EntityInheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; ActiveSupport::TestCase&lt;/span&gt;&lt;/span&gt;
  set_fixture_class &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;elp&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Variable&quot;&gt;User&lt;/span&gt;
  fixtures &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;elp&lt;/span&gt;
  
  test &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;ELP should be loaded through YAML file&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;do&lt;/span&gt;
    assert_equal &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;%w[&lt;/span&gt;Carl Greg Keith&lt;span class=&quot;String&quot;&gt;]&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Support&quot;&gt;User&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;all&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;name&lt;/span&gt;).&lt;span class=&quot;Entity&quot;&gt;sort&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;しかし、今の Railsのデフォルトでは test/test_helper.rb に&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;fixtures &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;all&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;とか書いてあったりするので、fixturesディレクトリ直下にこんなファイルが置いてあると、全てのテストケースでこの ymlファイルを同名のテーブルにロードしに行こうとしてガンガン落ちる。&lt;/p&gt;
&lt;p&gt;そこで、上記の1番の例を思い出して、特定のテストケースでのみ使いたいようなテストデータはサブディレクトリに置いとけば良いじゃん、というのがトレンドになりそう。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;$ mkdir test/fixtures/users
$ mv test/fixtures/elp.yml test/fixtures/users/
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;テストはこんなふうに書けば、&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;i&gt;test/unit/user_test.rb&lt;/i&gt;&lt;/strong&gt;&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;test_helper&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;JEntityNameType&quot;&gt;UserTest&lt;span class=&quot;EntityInheritedClass&quot;&gt; &lt;span class=&quot;EntityInheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; ActiveSupport::TestCase&lt;/span&gt;&lt;/span&gt;
  set_fixture_class &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:'&lt;/span&gt;users/elp&lt;span class=&quot;Constant&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Variable&quot;&gt;User&lt;/span&gt;
  fixtures &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:'&lt;/span&gt;users/elp&lt;span class=&quot;Constant&quot;&gt;'&lt;/span&gt;&lt;/span&gt;

  test &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;ELP should be loaded through YAML file&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;do&lt;/span&gt;
    assert_equal &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;%w[&lt;/span&gt;Carl Greg Keith&lt;span class=&quot;String&quot;&gt;]&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Support&quot;&gt;User&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;all&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;name&lt;/span&gt;).&lt;span class=&quot;Entity&quot;&gt;sort&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;$ rake test:units
(中略)
1 tests, 1 assertions, 0 failures, 0 errors
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;カンペキ！&lt;br /&gt;
ポイントは、ディレクトリ名とファイル名をつなげたものを引用符で囲って書くところでしょうか。&lt;/p&gt;
&lt;p&gt;以上、こんな感じで回答になってますでしょうか？ &amp;gt; 川端さん&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.dio.jp/">
    <author>
      <name>Akira Matsuda</name>
    </author>
    <id>tag:blog.dio.jp,2008-07-23:40</id>
    <published>2008-07-23T14:47:00Z</published>
    <updated>2008-07-23T15:50:43Z</updated>
    <category term="EDGE"/>
    <category term="Rails"/>
    <link href="http://blog.dio.jp/2008/7/23/installing-plugin-by-git-with-tag" rel="alternate" type="text/html"/>
    <title>Git&#12391;&#12503;&#12521;&#12464;&#12452;&#12531;&#12434;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&#12377;&#12427;&#26178;&#12395;&#12496;&#12540;&#12472;&#12519;&#12531;&#25351;&#23450;&#12364;&#12391;&#12365;&#12427;&#12424;&#12358;&#12395;&#12394;&#12387;&#12383;</title>
<content type="html">
            &lt;p&gt;昨今の Gitブームを受けて、Rails 2.1 から script/plugin スクリプトが Gitに対応したのは記憶に新しいところ。&lt;/p&gt;
&lt;p&gt;だが、このコマンドでは単に Gitリポジトリの最新版を取得してきてしまうため、みんな &lt;a href=&quot;http://twitter.com/darashi/statuses/847668361&quot;&gt;こんな&lt;/a&gt; 疑問を抱えながら使っていたわけだが、実は Gitでタグ付けされた安定版を導入しようと思ったら、script/pluginにはそんなオプションは用意されていなかったので、 &lt;a href=&quot;http://github.com/dchelimsky/rspec-rails/wikis/home&quot;&gt;こんなふうな&lt;/a&gt; 面倒な手順を踏まなければならなかった。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;$ cd vendor/plugins
$ git clone git://github.com/dchelimsky/rspec.git
$ git clone git://github.com/dchelimsky/rspec-rails.git
$ cd rspec
$ git checkout 1.1.4
$ cd ../rspec-rails
$ git checkout 1.1.4
$ cd ..
$ rm -rf rspec/.git
$ rm -rf rspec-rails/.git
$ cd ../../
$ script/generate rspec
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;これを解消すべく &lt;a href=&quot;http://rails.lighthouseapp.com/projects/8994/tickets/257&quot;&gt;こんな&lt;/a&gt; チケットが挙がっていた、というのは、これまた RubyKaigiの時に書いた &lt;a href=&quot;http://docs.google.com/View?docid=ddn3rmd_13grtgctcg&quot;&gt;これ&lt;/a&gt; に書いたとおりだが、その後この dchelimsky案よりもっとエレガントな実装が行われ、 &lt;a href=&quot;http://github.com/rails/rails/commit/5c086070824bf7dd2bc4c9ce97956d82ac3fa206&quot;&gt;先日コミットされた&lt;/a&gt; 。&lt;/p&gt;
&lt;p&gt;これによって、結論としては、今の edge Railsでは以下のコマンドで任意のタグがついたバージョンのプラグインをインストールすることができるようになった。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;$ ./script/plugin install git://github.com/dchelimsky/rspec.git -r &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;tag 1.1.4&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;しかも、試してみればわかるが、Subversionのころと比べると驚異的に速い！！&lt;br /&gt;
これでもはや Railsプラグインが Gitに移行しない理由はひとつもなくなったと言って良いのではないだろうか。&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.dio.jp/">
    <author>
      <name>Akira Matsuda</name>
    </author>
    <id>tag:blog.dio.jp,2008-07-23:39</id>
    <published>2008-07-23T11:03:00Z</published>
    <updated>2008-07-23T11:08:11Z</updated>
    <category term="EDGE"/>
    <category term="Rails"/>
    <link href="http://blog.dio.jp/2008/7/23/instantiating-through-named_scope" rel="alternate" type="text/html"/>
    <title>named_scope&#12364;&#12452;&#12531;&#12473;&#12479;&#12531;&#12473;&#29983;&#25104;&#26178;&#12395;&#12418;&#20351;&#12360;&#12427;&#12424;&#12358;&#12395;&#12394;&#12387;&#12383;</title>
<content type="html">
            &lt;p&gt;ちょっと前の話だが、 &lt;a href=&quot;http://github.com/rails/rails/commit/84af99e78dbf65b7faa92313acf8457cb0c2b510&quot;&gt;こちらのコミット&lt;/a&gt; にて、hashで条件指定された named_scopeを経由してモデルのインスタンス生成を行った場合、その条件の値があらかじめセットされたインスタンスが作られるようになった(この件については、 &lt;a href=&quot;http://docs.google.com/Doc?docid=ddn3rmd_13grtgctcg&amp;amp;hl=en&quot;&gt;こちら&lt;/a&gt; の「注目の未解決チケットたち」に書いたとおり以前から &lt;a href=&quot;http://rails.lighthouseapp.com/projects/8994/tickets/419&quot;&gt;要望が挙がっていた&lt;/a&gt; もの)。&lt;br /&gt;
どういうことかというと、例えばこんな感じ。&lt;/p&gt;
&lt;p&gt;こんなようなmodelがあるとして、&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;JEntityNameType&quot;&gt;User&lt;span class=&quot;EntityInheritedClass&quot;&gt; &lt;span class=&quot;EntityInheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; ActiveRecord::Base&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;SupportFunction&quot;&gt;belongs_to&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;prefecture&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; 引数を取らない named_scope&lt;/span&gt;
  &lt;span class=&quot;Support&quot;&gt;Prefecture&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;all&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;do &lt;/span&gt;|&lt;span class=&quot;Variable&quot;&gt;prefecture&lt;/span&gt;|
    named_scope &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;lives_in_&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;prefecture&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Entity&quot;&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Entity&quot;&gt;downcase&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;to_sym&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;conditions&lt;/span&gt; =&amp;gt; {&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;prefecture_id&lt;/span&gt; =&amp;gt; prefecture.&lt;span class=&quot;Entity&quot;&gt;id&lt;/span&gt;}
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt; 
&lt;span class=&quot;Comment&quot;&gt;  &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; 引数を取る named_scope&lt;/span&gt;
  named_scope &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;name_is&lt;/span&gt;, &lt;span class=&quot;Support&quot;&gt;Proc&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt; {|&lt;span class=&quot;Variable&quot;&gt;name&lt;/span&gt;| {&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;conditions&lt;/span&gt; =&amp;gt; {&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;name&lt;/span&gt; =&amp;gt; name}}}
  named_scope &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;aged&lt;/span&gt;, &lt;span class=&quot;Support&quot;&gt;Proc&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt; {|&lt;span class=&quot;Variable&quot;&gt;age&lt;/span&gt;| {&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;conditions&lt;/span&gt; =&amp;gt; {&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;age&lt;/span&gt; =&amp;gt; age}}}
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;まずはふつうに検索。&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Support&quot;&gt;User&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;lives_in_tokyo&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;name_is&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;Matsuda&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).&lt;span class=&quot;Entity&quot;&gt;aged&lt;/span&gt;(&lt;span class=&quot;Constant&quot;&gt;16&lt;/span&gt;)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;発行されるSQL&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;User Load (&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;Constant&quot;&gt;000373&lt;/span&gt;)
   &lt;span class=&quot;Keyword&quot;&gt;SELECT&lt;/span&gt; * &lt;span class=&quot;Keyword&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&amp;quot;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;WHERE&lt;/span&gt; (((&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&amp;quot;&lt;/span&gt;.&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;age&amp;quot;&lt;/span&gt; = &lt;span class=&quot;Constant&quot;&gt;16&lt;/span&gt;) &lt;span class=&quot;Keyword&quot;&gt;AND&lt;/span&gt; (&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&amp;quot;&lt;/span&gt;.&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;name&amp;quot;&lt;/span&gt; = &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;Matsuda'&lt;/span&gt;)) &lt;span class=&quot;Keyword&quot;&gt;AND&lt;/span&gt; (&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&amp;quot;&lt;/span&gt;.&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;prefecture_id&amp;quot;&lt;/span&gt; = &lt;span class=&quot;Constant&quot;&gt;13&lt;/span&gt;))
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;ここまでは今までどおり。&lt;br /&gt;
これを newとか createとかにつなげるとこうなるッ！&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;user &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;User&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;lives_in_tokyo&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;name_is&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;Matsuda&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).&lt;span class=&quot;Entity&quot;&gt;aged&lt;/span&gt;(&lt;span class=&quot;Constant&quot;&gt;16&lt;/span&gt;).create
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;実行結果&lt;/p&gt;&lt;table class=&quot;jazzy&quot;&gt;&lt;tr&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;User Create (&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;Constant&quot;&gt;001407&lt;/span&gt;)
   &lt;span class=&quot;Keyword&quot;&gt;INSERT INTO&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;users&amp;quot;&lt;/span&gt; (&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;name&amp;quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;created_at&amp;quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;updated_at&amp;quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;age&amp;quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;prefecture_id&amp;quot;&lt;/span&gt;) &lt;span class=&quot;Keyword&quot;&gt;VALUES&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;Matsuda'&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;2008-07-23 18:09:27'&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;2008-07-23 18:09:27'&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;16&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;13&lt;/span&gt;)
  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;=&amp;gt; #&amp;lt;User id: 1, name: &amp;quot;Matsuda&amp;quot;, age: 16, prefecture_id: 13, created_at: &amp;quot;2008-07-23 18:09:27&amp;quot;, updated_at: &amp;quot;2008-07-23 18:09:27&amp;quot;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;かっこいー！&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.dio.jp/">
    <author>
      <name>Akira Matsuda</name>
    </author>
    <id>tag:blog.dio.jp,2008-07-23:38</id>
    <published>2008-07-23T00:09:00Z</published>
    <updated>2008-07-23T00:50:26Z</updated>
    <category term="EDGE"/>
    <category term="Mephisto"/>
    <category term="Ruby"/>
    <link href="http://blog.dio.jp/2008/7/23/redcloth-4-0-released" rel="alternate" type="text/html"/>
    <title>RedCloth 4.0 Released</title>
<content type="html">
            &lt;p&gt;待望の &lt;a href=&quot;http://www.rubyinside.com/redcloth-4-released-962.html&quot;&gt;RedCloth 4.0がリリースされた&lt;/a&gt; 。&lt;/p&gt;
&lt;p&gt;さっそくこのブログのサーバにも入れてみたので、このポストが RedCloth 4.0で書く最初の文章になるかな。&lt;/p&gt;
&lt;p&gt;そもそも、このブログは &lt;a href=&quot;http://github.com/technoweenie/mephisto/tree/master&quot;&gt;Mephisto 0.8 (Drax) の Gitの先っちょ版&lt;/a&gt; で書いているのだが、この Mephistoはデフォルトでは RedClothの3.0.4をバンドルして使っていて、改行が &amp;lt;br&amp;gt; になってくれないという致命的に使いにくいブログシステムだった。&lt;br /&gt;
ので、 &lt;a href=&quot;http://code.whytheluckystiff.net&quot;&gt;_why先生のリポジトリ&lt;/a&gt; から 3.301という開発版を取ってきてちょっと拡張して使っていたのだが、このたび 4.0が正式にリリースされたので全面的に乗り換えてみた(そこらへんの手順とかTIPSとかは自分のためにも気が向いたらあとで書く)。&lt;/p&gt;
&lt;p&gt;この RedCloth 4.0が出たおかげで、Rubyで作られた Wikiとかブログとか CMSとかその手のツールもだいぶ使いやすくなって盛り上がってくるんじゃないかな。&lt;br /&gt;
やっぱりこういうやつってそこらへんの足回りがかなり重要なので。&lt;/p&gt;
&lt;p&gt;そして、RedClothといえば、3.0.4をめっちゃオレオレ拡張して組み込んでる  &lt;a href=&quot;http://www.redmine.org/repositories/entry/redmine/trunk/lib/redcloth.rb&quot;&gt;Redmine&lt;/a&gt; とかがどう対応するのかも気になるところですよね。&lt;/p&gt;
          </content>  </entry>
</feed>
