<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 <title>Blog on AIRS</title>
 <link href="http://blog.airs.co.jp/feed/atom.xml" rel="self"/>
 <link href="http://blog.airs.co.jp/"/>
 <updated>2010-01-29T16:52:43+09:00</updated>
 <id>http://blog.airs.co.jp/</id>
 <author>
   <name>AIRS inc.</name>
 </author>

 
 <entry>
   <title>RailsのMigrationでMySQLのカラムコメントを使う</title>
   <link href="http://blog.airs.co.jp/2009/02/20/rails-migration-mysql-column-comment.html"/>
   <updated>2009-02-20T08:41:00+09:00</updated>
   <id>/2009/02/20/rails-migration-mysql-column-comment.html</id>
   <content type="html">&lt;p&gt;加藤です。&lt;/p&gt;
&lt;p&gt;MySQLの4.1以降ではテーブルの作成時やALTER TABLEでカラムを変更する際に、下のようにカラムコメントを付けることが出来ます。&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;TABLE&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;`&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;`&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;NULL&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;auto_increment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;`&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;NULL&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;COMMENT&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;氏名: 日本語可。50文字以内。&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;email&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;`&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;COMMENT&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;メールアドレス: 半角英数文字のみ。100文字以内。&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;PRIMARY&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;KEY&lt;/span&gt;  &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; 
&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;また、付けたコメントは下のようなSQLで取得することが出来ます。&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;mysql&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;SHOW&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;FULL&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;COLUMNS&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;このMySQLのカラムコメントをRailsのマイグレーションで簡単に設定できるようにすれば、ドキュメント生成なんかに使いまわせてDRYで便利じゃないかということでパッチを書きました。&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;ActiveRecord&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;ConnectionAdapters&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ColumnDefinition&lt;/span&gt;
      &lt;span class=&quot;kp&quot;&gt;attr_accessor&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:comment&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;to_commented_sql&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;comment&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;to_sql&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; COMMENT &amp;#39;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;comment&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;#39;&amp;quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;to_sql&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;to_s&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:to_commented_sql&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TableDefinition&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:_orig_column&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:column&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;options&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{})&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;_orig_column&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;comment&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:comment&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
          &lt;span class=&quot;n&quot;&gt;column&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;vi&quot;&gt;@columns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;find&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;col&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;col&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
          &lt;span class=&quot;n&quot;&gt;pos&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;vi&quot;&gt;@columns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
          &lt;span class=&quot;vi&quot;&gt;@columns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pos&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;comment&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;comment&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;self&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;これを&lt;code&gt;config/initializers/column_comment.rb&lt;/code&gt;あたりに置いておけば、マイグレーションでのテーブル作成時にカラムコメントを設定出来るようになります。&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CreateUsers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ActiveRecord&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Migration&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;up&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;create_table&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:users&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:null&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:limit&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:comment&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;氏名: 日本語可。50文字以内。&amp;#39;&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:limit&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:comment&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;メールアドレス: 半角英数文字のみ。100文字以内。&amp;#39;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;down&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;drop_table&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:users&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;</content>
 </entry>
 
 <entry>
   <title>Windowsで最新のRailsをJRubyで動かす。</title>
   <link href="http://blog.airs.co.jp/2008/12/13/jruby_on_rails_on_windows.html"/>
   <updated>2008-12-13T13:24:00+09:00</updated>
   <id>/2008/12/13/jruby_on_rails_on_windows.html</id>
   <content type="html">&lt;p&gt;こんにちは。石上です。&lt;/p&gt;
&lt;p&gt;Windows Vista上で最新のRailsをJRubyで動かしたいと思います。少し前まで、JRubyなんて…と思っていましたが、jrubystackを利用したら思いのほか上手く動いたので、報告したいと思います。Java屋の人で、Windows環境でRails開発始めたいと思っている人は注目かもしれません。&lt;/p&gt;
&lt;p&gt;jrubystackは、Jruby on Railsの開発環境に必要なソフトウェア一式を一度に整えることが出来るソフトウェアです。GlassFish、Java、JDBC、MySQL、Ruby on Rails、Subversion、Tomcatなどから構成されます。そのため、何もインストールされていない状態でも、Railsの開発環境を得ることが出来ます。&lt;/p&gt;
&lt;p&gt;まず最初に行うのは、jrubystackのインストールです。&lt;a href=&quot;http://bitnami.org/stack/jrubystack&quot;&gt;公式サイト&lt;/a&gt;から、Windows版のバイナリをダウンロードし、インストーラーを起動します。今回は、JRubyStack 1.1.4-0（JDK含む）を利用しました。&lt;/p&gt;
&lt;p&gt;インストールはウィザードに従っていけば良いですが、MySQLを既にインストールしている人は注意が必要です。既にインストールしてあるMySQLとJrubystackでインストールされるMySQLのポート番号が被らないようにしましょう。私は「13306」にしました。&lt;/p&gt;
&lt;p&gt;自動的にコマンドプロンプトが立ち上がり、暫くしてブラウザに「Welcome aboard」と表示されたらJRubyStackのインストールは完了です。開いたコマンドプロンプトとブラウザは一旦閉じてください。&lt;/p&gt;
&lt;p&gt;JrubyStackを起動します。Windowsのスタートメニューから、[スタート] &amp;#8594; [BitNami JRubyStack] &amp;#8594; [Use Bit Nami JRubyStack]を管理者権限で起動させ、コマンドプロンプトが立ち上がることを確認してください。&lt;/p&gt;
&lt;p&gt;JrubyStackに既にインストールされているRailsは、2.1.0と少し古いので最新版にします。&lt;/p&gt;
&lt;pre&gt;
&amp;gt; jruby -S gem install 
Successfully installed rake-0.8.3
Successfully installed activesupport-2.2.2
Successfully installed activerecord-2.2.2
Successfully installed actionpack-2.2.2
Successfully installed actionmailer-2.2.2
Successfully installed activeresource-2.2.2
Successfully installed rails-2.2.2
7 gems installed
&lt;/pre&gt;
&lt;p&gt;次に、gem自体をアップデートします。参考：&lt;a href=&quot;http://www.func09.com/wordpress/archives/252&quot;&gt;gemが1.3.xにバージョンアップできない件&lt;/a&gt;&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
&amp;gt; jruby -S gem install rubygems-update&lt;br /&gt;
&amp;gt; jruby -S update_rubygems&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Railsのプロジェクトを展開します。&lt;/p&gt;
&lt;pre&gt;
&amp;gt; jruby -S rails test -d mysql
&lt;/pre&gt;
&lt;p&gt;testというディレクトリが作成されたと思います。以降は、testディレクトリで作業をします。&lt;/p&gt;
&lt;p&gt;DBの設定&lt;br /&gt;
「config\database.yml」を編集します。以下の様な感じで設定します。&lt;/p&gt;
&lt;pre&gt;
development:
  adapter: jdbcmysql
  database: jrubystack_development
  username: jrubystack
  password: 
  host: localhost
  socket: C:\Program Files\BitNami JRubyStack/mysql/tmp/mysql.sock
  port: 13306
&lt;/pre&gt;
&lt;p&gt;雛形の作成&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
&amp;gt; jruby -S script/generate scaffold person name:string age:integer&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;データベーススキーマの作成&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
&amp;gt; jruby -S rake db:migrate&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;サーバーの起動&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
&amp;gt; jruby -S script/server&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;ブラウザでの確認&lt;br /&gt;
http://localhost:3000/people/&lt;/p&gt;
&lt;p&gt;どうでしたか。「jruby -S」以外の部分を除けば、普通のRailsアプリケーションの構築とほとんど変わらないと思います。是非とも、スレッドセーフなJRuby on Railsを楽しんでください。&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>RailsとGWT &quot;混ぜるな危険&quot; にしない5つのポイント</title>
   <link href="http://blog.airs.co.jp/2008/10/09/gwt_and_rails.html"/>
   <updated>2008-10-09T12:45:00+09:00</updated>
   <id>/2008/10/09/gwt_and_rails.html</id>
   <content type="html">&lt;p&gt;加藤です。しばらくぶりの更新です。&lt;br /&gt;
ここ最近はRailsとGWTの組み合わせを色々と検証しています。&lt;/p&gt;
&lt;p&gt;GWTといえばJava言語でJavaScriptアプリケーションを書くためのツールという認識が一般的だと思いますが、実際に触ってみると、これは軽くて速いJavaScriptコードを生成するための道具なんだなということが判ります。また全世界で展開するGoogleが開発しているしているだけあって、国際化の仕組みが標準で組み込まれているのも日本人にとってうれしいところです。&lt;/p&gt;
&lt;p&gt;Railsとの連携についての詳しい内容はいずれここで紹介したいと思いますが、Flexなどと比べるとGWTはあまりにもスルーされてる感があるので、差し当たりこれまでにハマった経験をもとにいくつかポイントを晒したいと思います。&lt;/p&gt;
&lt;h2&gt;その1: データ交換はJSONでおこなう&lt;/h2&gt;
&lt;p&gt;まぁ、そりゃそうだろといわれればそうなんですが、データ交換はJSONでおこなうのが一番ラクです。最近正式にリリースされたGWT1.5ではJavaScriptとの連携が強化されたのですが、その中のひとつである &lt;a href=&quot;http://googlewebtoolkit.blogspot.com/2008/08/getting-to-really-know-gwt-part-2.html&quot;&gt;JavaScript Overlay Types&lt;/a&gt; をつかうとJSONコードをパースによるオーバヘッド無しでGWT内のJavaオブジェクトに変換出来ます。&lt;/p&gt;
&lt;p&gt;Rails側のモデルをto_jsonで返して、GWT側ではJavaScript Overlay Typesで受け取ってモデルの基底クラスにNULLチェックや型変換を書いておくのが、今のところベストな方法です。&lt;/p&gt;
&lt;h2&gt;その2: &lt;span class=&quot;caps&quot;&gt;GWT&lt;/span&gt; on Railsは使えない&lt;/h2&gt;
&lt;p&gt;というのは言い過ぎのような気もしますが、GWTとRailsで調べるとすぐに出てくる &lt;a href=&quot;http://code.google.com/p/gwt-on-rails/&quot;&gt;&lt;span class=&quot;caps&quot;&gt;GWT&lt;/span&gt; on Rails&lt;/a&gt; はあまりおすすめ出来ません。最近メンテナンスされていないので、Rails 2.1やGWT 1.5 にまだ対応していないというのが理由のひとつです。また、GWT on RailではRailsとGWTのコードをジェネレータで同時に生成するのですが、これだとどちらも自由度が下がってしまいます。例えば、RSpec使いたいとかMaven使いたいとかいう時には大変不便です。&lt;/p&gt;
&lt;p&gt;他にGWTとRailsの連携を助けるツールとして、 &lt;a href=&quot;http://code.google.com/p/gwt-rest/&quot;&gt;&lt;span class=&quot;caps&quot;&gt;GWT&lt;/span&gt;-&lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt;&lt;/a&gt; がありますが、これも長らく更新されていませんし、GWT-RESTで出来ることは前述のJavaScript Overlay Typesで出来ることと変わらないので特に使うメリットはありません。&lt;/p&gt;
&lt;h2&gt;その3: GWTとRJSの連携はやりすぎ&lt;/h2&gt;
&lt;p&gt;GWTが生成するのは普通のHTMLとJavaScriptなので、やろうと思えばRJSとも簡単に連携できます。例えば、GWTからのHTTPリクエストを受け取ったRailsアクションがサーバー側でRJSをつかってHTML上のDOM要素を書き換えてしまってもまったく問題無いわけです。また、RJSで書き換えたコンポーネントからアンカーをつかってURLを変更しGWT側でそれを検知することで、RJSからGWT側に操作を伝えることも出来ます。&lt;/p&gt;
&lt;p&gt;僕も最初は、これなら必要なコンポーネントを遅延ロードさせることが出来るし、簡単なフォームならRJSの方がラクだからこの組み合わせは完璧だねと思ったのですが、クライアント側の処理コードが分散すると1ヶ月もしないうちに書いた人間すら判らない状態になってしまうので、最終的に全部GWT側にまとめました。&lt;/p&gt;
&lt;p&gt;ただアイデア自体は悪くないと思います。いずれフレームワークが出てくるかもしれないので、それまで待ちましょう（もしくは作りましょう）。&lt;/p&gt;
&lt;h2&gt;その4: 認証はRailsでページ遷移させておこなう&lt;/h2&gt;
&lt;p&gt;色々と調べている中で、GWT関連の書籍やブログに「GWTアプリケーションは単独のHTMLページ内で動作し、ログインもその中でおこなわれます」みたいなことが書かれているのを見たのですが、セキュリティ上かなり難しいと思いますし、そうするメリットもあまりないように思います。OpenIDやその他の認証プロバイダを使う場合は現実的にかなり困難です。&lt;/p&gt;
&lt;p&gt;ここは割り切ってRails側でrestful-authenticationあたりをつかってさくっと作りましょう。ホストページ（GWTアプリケーションが動作するコンテナとなるHTMLページ）に初期データを埋め込んでおけば、HTTPリクエストが減らせてGWTアプリケーションの起動も早くできます。&lt;/p&gt;
&lt;h2&gt;その5: GWTの拡張ライブラリは必須&lt;/h2&gt;
&lt;p&gt;これはRailsとは直接関係の無いGWT側のポイントですが、GWTの標準ライブラリにはかなりプリミティブなものしか無いので、拡張ライブラリは必須です。メジャーなものとして、 &lt;a href=&quot;http://code.google.com/p/google-web-toolkit-incubator/&quot;&gt;&lt;span class=&quot;caps&quot;&gt;GWT&lt;/span&gt; incubator&lt;/a&gt; と &lt;a href=&quot;http://code.google.com/p/gwtx/&quot;&gt;GWTx&lt;/a&gt; の2つは最初から導入しておきましょう。&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;GWT&lt;/span&gt; incubatorはGoogleが提供するベータ版ライブラリのような位置づけでかなりボリュームがありますが、良く使うのはロギングや拡張されたGUIウィジェットなどです。また、これはまだ検証できていませんが少し面白いものとして、GWTのコンパイル時にCSSを最適化する &lt;a href=&quot;http://code.google.com/docreader/#p=google-web-toolkit-incubator&amp;amp;s=google-web-toolkit-incubator&amp;amp;t=CssResource&quot;&gt;CSSResource&lt;/a&gt; なんてものもあります。&lt;/p&gt;
&lt;p&gt;GWTxはGWTのJREエミュレーションから漏れたJava標準ライブラリを補完するライブラリで、モデルの変更をオブザーブするためのProperty Change Listenerを良く使います。最近リリースされたGWT1.5対応版では、java.beans.Introspectorやjava.beans.BeanInfoなども追加されたようなので、標準でリフレクションが使えないGWTではますます重宝されそうです。&lt;/p&gt;
&lt;p&gt;また、Ext JSについてあまり詳しくないのでまだ使用したことはありませんが、Ext JSとの連携ライブラリとして、&amp;quot;Ext GWT&amp;quot;:http://extjs.com/products/gxt/ や &lt;a href=&quot;http://code.google.com/p/gwt-ext/&quot;&gt;&lt;span class=&quot;caps&quot;&gt;GWT&lt;/span&gt;-Ext&lt;/a&gt; などがあります。見た目が固定化されてしまいそうな点がちょっと気になりますが、GUIコンポーネントが豊富に揃っているので社内用のアプリケーション開発などには良いのではないでしょうか。&lt;/p&gt;
&lt;p&gt;その他、GWT版JQueryの &lt;a href=&quot;http://code.google.com/p/gwtquery/&quot;&gt;GwtQuery&lt;/a&gt; も要注目です。&amp;quot;Google I/Oのプレゼンテーション&amp;quot;:http://sites.google.com/site/io/gwt-extreme で開発者のRay Cromwellさんが、「縮小化・圧縮されたJQueryは15kb。コンパイル後のGwtQueryはどんだけだと思う？なんとたったの&lt;strong&gt;712bytes&lt;/strong&gt;だぜ（意訳）」とアピールされておりました。プラグインも書けるみたいです。&lt;/p&gt;
&lt;h2&gt;まとめ&lt;/h2&gt;
&lt;p&gt;ということで、色々と紹介しましたが少しはRailsとGWTの組み合わせに興味はもっていただけたでしょうか？&lt;/p&gt;
&lt;p&gt;あまり生産性は良くないなど色々と課題はありますが、GWTはJavaScriptハッカーじゃなくても高性能なJavaScriptアプリケーションが書ける貴重なツールです。登場から2年、正式リリースから1年以上経つにもかかわらず、ましてやGoogle印にもかかわらず、これまであまり注目されていなかった感がありますが、ブラウザの開発競争が激しくなる中で今後注目は高まっていくと思います。Railsやってる人もぜひ一度試してみて下さい。&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>onclickの無いRJSなんて</title>
   <link href="http://blog.airs.co.jp/2008/05/21/rjs_method_chain_and_highlight_hack.html"/>
   <updated>2008-05-21T10:57:00+09:00</updated>
   <id>/2008/05/21/rjs_method_chain_and_highlight_hack.html</id>
   <content type="html">&lt;p&gt;加藤です。もはやインラインRJSだらけなので、onclickダメとかいわれても困ります。&lt;/p&gt;
&lt;p&gt;ということでRJSネタなんですが、RJSでメソッドチェイン出来ることに今更気付きました。というか、対応するPrototypeやScript.aculo.usのメソッドがElementを返すことを知りませんでした。&lt;/p&gt;
&lt;p&gt;例えば、onClickで要素クラスを入れ替えてYellow Fadeさせる場合は以下のように書けます。&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;%=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;link_to_function&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;表示に戻る&amp;#39;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:item&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;remove_class_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:edit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add_class_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;visual_effect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:highlight&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;あとRJSとは直接関係ないですが、Effect.Highlightを使うと最終的な背景色がスタイル属性に書き込まれてしまい色々と副作用があります。一度エフェクトさせた後に背景色が変化しなくなるとか、エフェクトをかける度に背景色が濃くなっていくとったダサい状況は、これが原因であることが多いと思います。&lt;/p&gt;
&lt;p&gt;問題を解決するには、style属性のbackgroundColorをnullにしてあげれば良いのですが、エフェクトのキューの最後に実行したい事が多いので、新しいEffectクラスを作成して対応することにしました。&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nx&quot;&gt;Effect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ResetHighlight&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Class&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Effect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Base&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;initialize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;element&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;throw&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Effect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;_elementDoesNotExistError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;options&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;fps&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;duration&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;arguments&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;setup&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;setStyle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;backgroundColor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;finish&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;先ほどのRJSで使うと以下のようになります。&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sx&quot;&gt;%= link_to_function &amp;#39;表示に戻る&amp;#39; do |page|&lt;/span&gt;
&lt;span class=&quot;sx&quot;&gt;  page[:item].remove_class_name(:edit).add_class_name(:show).visual_effect(:highlight).visual_effect(:reset_highlight, { :queue =&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:end&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;ちなみに、どちらもまだFirefox3でしか確認していないのでブラウザ互換性については不明です。&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Rails2.0に対応したRadiant 0.6.6がリリース</title>
   <link href="http://blog.airs.co.jp/2008/04/29/rails2_0-radiant_0_6_6.html"/>
   <updated>2008-04-29T12:25:00+09:00</updated>
   <id>/2008/04/29/rails2_0-radiant_0_6_6.html</id>
   <content type="html">&lt;p&gt;お久しぶりです。インターンの石上です。&amp;quot;前回取り上げたRadiant&amp;quot;:http://labs.airs.co.jp/2008/2/7/radiantgettext-0_6_4 が&amp;quot;0.6.6として正式リリース&amp;quot;:http://radiantcms.org/blog/archives/2008/04/20/radiant-0-6-6&amp;#8212;-chiseled-release/ されました。そのため今日はRadiantの最新バージョンがどのように変わったのかを簡単に説明します。&lt;/p&gt;
&lt;p&gt;大きな変更点は以下のとおりです。些細なことですが、0.6.6が0.6.5が出た直後にリリースされたバグ修正版です。そのため、以下で紹介する機能追加は正確に言えば0.6.5から行われたものです。&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Rails 2.0.2の採用（0.6.4はRails 1.2.5）&lt;/li&gt;
	&lt;li&gt;RSpec 1.1.4の採用。本体のテストだけでなく、Extensionのテストでも利用できます。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;本体機能の変更点は以下の通りです。&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;ページの編集画面からpublish dateを変更できるようになりました。&lt;/li&gt;
	&lt;li&gt;r:find タグが相対パスでも利用できるようになりました。例えばページに「&lt;r:find url=&quot;./&quot;&gt;個別記事表示中&lt;r:find&gt;」と記述します。すると、記事単体を表示した時だけ、タグで囲まれた部分が表示することが出来ます。&lt;/li&gt;
	&lt;li&gt;サブディレクトリに設置しても管理画面やRadiusタグがルートディレクトリに設置したかのように配慮してくれるようになったそうです。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;次の機能が一番嬉しいのですが、&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;ページ毎にDescriptionやKeywordsをメタタグで埋め込めるようになりました。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;ページ毎にmetaタグを入れたいと場合について紹介しましょう。まず、管理画面からLayoutsを開き、適当なレイアウトファイルを開きます。そして、HTML中の&lt;head&gt;の間に以下のように記述します。&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:meta&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:description&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt; /&amp;gt;&lt;/span&gt;
&lt;span class=&quot;sr&quot;&gt;    &amp;lt;r:keywords /&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/r:meta&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;そして、ページ毎にKeywordsとDescriptionを設定します。すると、そのページを表示する際にmetaタグが表示されます。&lt;/p&gt;
&lt;h3&gt;インストール方法&lt;/h3&gt;
&lt;p&gt;インストール方法は、既存のRailsアプリと変わりません。簡単に説明したいと思います。&lt;/p&gt;
&lt;p&gt;まず、ダウンロードします。Gemでも入れることが出来ますが、今回はSVNレポジトリ経由で入れました。また、運用はしないのでDevelopment環境でインストールを行いました。&lt;/p&gt;
&lt;p&gt;まずはダウンロード。ちなみに&amp;quot;Gitでもダウンロード可能&amp;quot;:http://dev.radiantcms.org/#Contributions です。&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
svn co http://svn.radiantcms.org/radiant/trunk/radiant&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;利用するデータベースに合わせ設定ファイルを利用します。今回はMySQLを利用しました。&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
cp database.mysql.yml database.yml&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;データベースをMySQLに作成し、以下のコマンドでインストールを始めます。&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
rake development db:bootstrap  &lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;最後にサーバーの立ち上げて終わりです。&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
script/server&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;前のバージョンからアップグレードする方は1つだけ注意が必要です。0.6.5では内部構造が大きく変更されたので、config/environment.rbとconfig/boot.rbが大きく変更されています。アップグレードする方は、これらファイルのバックアップを取っておきましょう。&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Edge RailsのTimezoneサポートでサマータイムのこと忘れてハマる</title>
   <link href="http://blog.airs.co.jp/2008/04/19/rails-2_1-timezone-summer_time.html"/>
   <updated>2008-04-19T09:25:00+09:00</updated>
   <id>/2008/04/19/rails-2_1-timezone-summer_time.html</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://labs.airs.co.jp/2008/4/16/rails-2_1-edge-rails&quot;&gt;先日導入したEdge Rails&lt;/a&gt; のタイムゾーンサポートのおかげで、Railsアプリケーションでの日別レポート出力なんかがグッと楽になったのですが、USタイムゾーンでのレポートでテストにこける時が出てきました。&lt;/p&gt;
&lt;p&gt;思いつくことといえばサマータイムなので調べてみます（本当はここに辿り着くまでにMySQLで何とかしようとしてハマりましたが。。。）&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zone&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;Central Time (US &amp;amp; Canada)&amp;#39;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;Central Time (US &amp;amp; Canada)&amp;quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zone&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;formatted_offset&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;-06:00&amp;quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zone&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;now&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Sat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;19&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Apr&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2008&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;03&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;46&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;21&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;CDT&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mo&quot;&gt;05&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mo&quot;&gt;00&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zone&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;formatted_offset&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;-05:00&amp;quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;そりゃそうだ。&amp;quot;now&amp;quot;も付けずにサマータイムかどうかなんて判断できませんよね。&lt;code&gt;Time.zone.formatted_offset&lt;/code&gt;を&lt;code&gt;Time.zone.now.formatted_offset&lt;/code&gt;に修正して、あっさり解決です。&lt;/p&gt;
&lt;p&gt;MySQLにUTCで保存されているデータから、当日追加されたユーザー数を見る場合だとこんな感じ。&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;no&quot;&gt;Time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zone&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;vi&quot;&gt;@current_user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timezone&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zone&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;formatted_offset&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;today&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zone&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strftime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;%Y-%m-%d&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;no&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:conditions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&amp;quot;DATE(CONVERT_TZ(created_at, &amp;#39;+00:00&amp;#39;, :offset)) = :today&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:offset&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:today&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;today&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;</content>
 </entry>
 
 <entry>
   <title>Rails 2.0.2で開発中のアプリケーションをEdge Railsにあげてみた</title>
   <link href="http://blog.airs.co.jp/2008/04/16/rails-2_1-edge-rails.html"/>
   <updated>2008-04-16T10:04:00+09:00</updated>
   <id>/2008/04/16/rails-2_1-edge-rails.html</id>
   <content type="html">&lt;p&gt;Rails 2.1で導入されるタイムゾーンサポートを開発中のアプリケーションでどうしても使いたくなったので、Edge Railsにあげてみました。意外とひっかかるところが多かったので、以下ググって潰した作業メモです。&lt;/p&gt;
&lt;p&gt;まず、Edge RailsをGithubのリポジトリからvender以下にチェックアウト。&lt;/p&gt;
&lt;pre&gt;
% cd &amp;lt;RAILS_ROOT&amp;gt;/vendor
% git clone git://github.com/rails/rails.git
&lt;/pre&gt;
&lt;p&gt;テストを実行して壊れたところを確認。&lt;/p&gt;
&lt;pre&gt;
% rake spec
...EE..E.E........F.........FF.....
...
&lt;/pre&gt;
&lt;p&gt;何かいっぱい出たので順番に潰していきます。&lt;/p&gt;
&lt;p&gt;まず、コントローラーのテストで、&amp;quot;You called render with invalid options:&amp;#8230;&amp;quot;のようなエラーが出ていたので調べたところ、RSpecのエラーで最新のtrunkでは修正されていました。&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://rspec.lighthouseapp.com/projects/5645/tickets/294-controller-examples-fail-when-calling-render&quot;&gt;Controller examples fail when calling render&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;最新のRSpecやRSpec-RailsのリポジトリもGithubにあるのですが、僕がチェックアウトした時はバージョンがうまくあわなかったので、今回はRubyforgeのtrunkにスイッチするようにしました。&lt;/p&gt;
&lt;pre&gt;
% ruby script/plugin install -x svn://rubyforge.org/var/svn/rspec/trunk/rspec --force
% ruby script/plugin install -x svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails --force
% ruby script/generate rspec
&lt;/pre&gt;
&lt;p&gt;これでRSpecのバージョンをあがったので再度テストしたところ、今度はヘルパーのテストで&lt;code&gt;'metaclass'&lt;/code&gt;メソッドが見つからなくなってしまいました。RSpecの1.1.4で取り除かれたようです。&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://rspec.rubyforge.org/svn/trunk/rspec/CHANGES&quot;&gt;RSpec &lt;span class=&quot;caps&quot;&gt;CHANGES&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;ここに書かれた通り、ヘルパーのテストを以下のように書き換えて対応します。もしくは、テストファイルを修正していないようであれば&lt;code&gt;script/generate rspec_controller Foo&lt;/code&gt;を再実行して、foo_helper_spec.rbのみを上書きしてもOKです。&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;should include the FooHelper&amp;quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;included_modules&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;send&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:included_modules&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;included_modules&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;should&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;FooHelper&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;次に、will_paginateで&amp;#8217;stack level too deep&amp;#8217; が出ていたので調べたところ、最新の2.2.1では直っていました。&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://groups.google.com/group/rubyonrails-core/browse_thread/thread/4a413d58e7931c11/13ee5a15a786418d?lnk=raot&quot;&gt;Release 9200 produces SystemStackError&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;will_paginateのリポジトリもGithubに移っていて、今後はプラグインよりもgemの方を使うように推奨されていたのでいわれた通りにします。&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://rock.errtheblog.com/will_paginate&quot;&gt;will_paginate&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;
% rm -rf vendor/plugins/will_paginate
% sudo gem install will_paginate
&lt;/pre&gt;
&lt;p&gt;また、プラグインではなくなったので、アプリケーション側で明示的にwill_paginateを読み込んであげる必要があります。Rails 2.1からgemの依存性を&lt;code&gt;config/environment.rb&lt;/code&gt;で指定できるようになったので、それを使ってみました。&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies&quot;&gt;What&amp;#8217;s New in Edge Rails: Gem Dependencies&lt;/a&gt;&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;no&quot;&gt;Rails&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Initializer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;run&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;will_paginate&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:version&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;2.2.1&amp;#39;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;最後にGettext Railsで&amp;#8217;file_exists?&amp;#8217;がundefinedになってしまっていたので、以下のページを参考に修正しました。僕の場合は、config/initializers/gettext.rb に以下のように記述しています。&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://zargony.com/2008/02/12/edge-rails-and-gettext-undefined-method-file_exists-nomethoderror&quot; title=&quot;NoMethodError&quot;&gt;Edge Rails and gettext: undefined method file_exists?&lt;/a&gt;&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;gettext/rails&amp;#39;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;ActionView&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Base&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;delegate&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:file_exists?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:to&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:finder&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;unless&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;respond_to?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:file_exists?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;以上で、全てのテストが通るようになりました。コンソールで新しいタイムゾーン機能を試してみます。&lt;/p&gt;
&lt;pre&gt;
% irb -rubygems -r config/environment
&amp;gt;&amp;gt; Time.zone
=&amp;gt; nil
&amp;gt;&amp;gt; Time.zone = 'UTC'
=&amp;gt; &quot;UTC&quot;
&amp;gt;&amp;gt; Time.zone.now
=&amp;gt; Wed, 16 Apr 2008 09:47:19 UTC +00:00
&amp;gt;&amp;gt; Time.zone = 'Asia/Tokyo'
=&amp;gt; &quot;Asia/Tokyo&quot;
&amp;gt;&amp;gt; Time.zone.now
=&amp;gt; Wed, 16 Apr 2008 18:47:39 JST +09:00
&lt;/pre&gt;
&lt;p&gt;大丈夫そうです。新しいタイムゾーンサポートの詳細については以下のエントリーが参考になります。&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://mad.ly/2008/04/09/rails-21-time-zone-support-an-overview/&quot;&gt;Rails 2.1 Time Zone Support: An Overview&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Edge Railsは2.1が正式にリリースされるまでの間、暫定的に使用するので、取りあえずGitで別管理とすることにして、アプリケーションのSubversionリポジトリからは除外しておくことにします。&lt;/p&gt;
&lt;pre&gt;
% svn propset svn:ignore 'rails' vendor
&lt;/pre&gt;
&lt;p&gt;タイムゾーンサポート以外にもHas FinderなどRails2.1の新機能は魅力的です。正式リリースが待ち遠しいですね。&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://weblog.rubyonrails.com/2008/4/1/a-taste-of-what-s-coming-in-rails-2-1&quot;&gt;A taste of what&amp;#8217;s coming in Rails 2.1&lt;/a&gt;&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Rails 2.0に対応したRadiant(trunk)の日本語化エクステンション</title>
   <link href="http://blog.airs.co.jp/2008/02/07/radiantgettext-0_6_4.html"/>
   <updated>2008-02-07T10:14:00+09:00</updated>
   <id>/2008/02/07/radiantgettext-0_6_4.html</id>
   <content type="html">&lt;p&gt;増田です。&lt;/p&gt;
&lt;p&gt;以前Radiantの日本語化エクステンションradiant-gettextを&amp;quot;紹介しました&amp;quot;:http://labs.airs.co.jp/2007/7/26/radiant-gettext%E3%82%A8%E3%82%AF%E3%82%B9%E3%83%86%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%9F%E6%97%A5%E6%9C%AC%E8%AA%9E%E5%8C%96 &lt;br /&gt;
が、あれからRadiantのバージョンも上がってそのまま使うわけにもいかなくなってきました。&lt;/p&gt;
&lt;p&gt;またRailsも2.0となり、どうせRadiantをいじるならRails 2.0で動かしたい、という人もいると思います。&lt;/p&gt;
&lt;p&gt;ちょうど数日前にRadiantのtrunkがRails 2.0に対応したので、&lt;br /&gt;
今回はリビジョン727のtrunkの日本語化エクステンションを作成してみました。&lt;br /&gt;
以下に導入の手順を示します。&lt;/p&gt;
&lt;p&gt;初めに必要なライブラリをgemでインストールしておきます。&lt;/p&gt;
&lt;pre&gt;
gem install radius
gem install gettext
&lt;/pre&gt;
&lt;p&gt;次にRadiantのtrunkをチェックアウトします。&lt;/p&gt;
&lt;pre&gt;
svn co  http://svn.radiantcms.org/radiant/trunk/radiant/ -r 727 radiant
&lt;/pre&gt;
&lt;p&gt;この中にbin/radiantというコマンドがあるのでこれでRadiant CMSを作成します。&lt;br /&gt;
ここではmy_siteという名前で作ってみます。&lt;/p&gt;
&lt;pre&gt;
/path/to/radiant/bin/radiant --database mysql my_site
&lt;/pre&gt;
&lt;p&gt;セットアップにtrunkのradiantが必要なので、vendorにエクスポートします。&lt;br /&gt;
radiantがRails 2.0.2もひっぱってきます。&lt;/p&gt;
&lt;pre&gt;
cd my_site
svn export http://svn.radiantcms.org/radiant/trunk/radiant/ -r 727 vendor/radiant
&lt;/pre&gt;
&lt;p&gt;config/database.ymlを適当に設定し、データベースを作成してからRadiantのセットアップに入ります。&lt;/p&gt;
&lt;pre&gt;
rake db:bootstrap
&lt;/pre&gt;
&lt;p&gt;radiant-gettextをvendor/extensions以下にエクスポートしてきます。&lt;/p&gt;
&lt;pre&gt;
svn export http://radiantgettext.rubyforge.org/svn/trunk/gettext vendor/extensions/gettext
&lt;/pre&gt;
&lt;p&gt;最後にradiant-gettextのセットアップをして終了です。&lt;/p&gt;
&lt;pre&gt;
rake radiant:extensions:gettext:setup
&lt;/pre&gt;
&lt;p&gt;翻訳のし忘れなど発見されましたらご連絡ください。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;追記(2008/05/06)：&lt;/strong&gt;&lt;br /&gt;
Radiant本家のSubversionリポジトリURLの変更にあわせてエクスポート元のURLを修正しました。&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>ActiveRecordに流れるようなインターフェイスを追加するActsAsFluented</title>
   <link href="http://blog.airs.co.jp/2007/11/02/acts_as_fluented.html"/>
   <updated>2007-11-02T05:26:00+09:00</updated>
   <id>/2007/11/02/acts_as_fluented.html</id>
   <content type="html">&lt;p&gt;加藤です。&lt;/p&gt;
&lt;p&gt;あまり考えることなく、海外ではやっていたらそれをそのまま受け入れる「舶来信仰」タイプの人間なので、これまで国産DIコンテナにはピクリとも食指が動かなかった非国民な自分でありますが、&amp;quot;S2JDBC&amp;quot;:http://s2container.seasar.org/2.4/ja/s2jdbc.html にはグッときました。&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://s2container.seasar.org/2.4/ja/s2jdbc_abstract.html#%E6%B5%81%E3%82%8C%E3%82%8B%E3%82%88%E3%81%86%E3%81%AA%E3%82%A4%E3%83%B3%E3%82%BF%E3%83%BC%E3%83%95%E3%82%A7%E3%83%BC%E3%82%B9%E3%81%A8%E8%84%B1CoC&quot;&gt;流れるようなインターフェースと脱CoC&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;CoCは、「規約を守っておけばフレームワークが自動的に設定してあげる」というもので、CoCによって開発者は、あまりソースコードを書かなくてもすむようになります。 CoCは、確かに私たちを設定ファイル地獄から救ってくれました。&lt;br /&gt;&lt;br /&gt;
しかし、CoCにも暗黒面があります。ソースコードに明示されている部分が少ないので、 自動化されている部分がブラックボックスになり、 規約を知らない人が見ると何をやっているのかがまったくわからなくなってしまうのです。&lt;br /&gt;&lt;br /&gt;
また、規約を知らないと何もできなくなるので、ちょっとしたことでも、自分の知らないことであれば、 いろいろ調べたり試行錯誤を繰り返すことになります。このような試行錯誤の時間は馬鹿になりません。 最終的なソースコードは確かに少なくなったけど、 かかった時間は大して変わらなかったなんてことも十分にありえます。 自動化されているので最初はとっつきやすいのですが、知らないことやイレギュラーなことに弱いのです。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Railsがイレギュラーなことに弱いとは全然思わないけれど、&amp;quot;流れるようなインターフェース&amp;quot;:http://capsctrl.que.jp/kdmsnr/wiki/bliki/?FluentInterface はイケてるので、早速ActiveRecordを使って真似してみました。が、書いた本人も使うつもりがないので以下は今のところネタです。タイトルを見てRailsプラグインの紹介だと思った方ごめんなさい。&lt;/p&gt;
&lt;h2&gt;ActsAsFluentedの使い方&lt;/h2&gt;
&lt;p&gt;まず、この下のファイルを&lt;code&gt;RAILS_ROOT/lib&lt;/code&gt;などクラスパスの通ったディレクトリに設置します。&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://labs.airs.co.jp/assets/2007/11/2/acts_as_fluented.rb&quot;&gt;acts_as_fluented.rb&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;次に、environment.rbに1行追加します。&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;no&quot;&gt;ActiveRecord&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Base&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:include&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ActsAsFluented&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;以上で、ActiveRecordモデルに&lt;code&gt;acts_as_fluented&lt;/code&gt;というクラスメソッドが追加されました。acts_as_fluentedが宣言されたモデルでは、&lt;code&gt;with_query(operator = :all) {|query| block}&lt;/code&gt;というクラスメソッドが使えるようになります。&lt;/p&gt;
&lt;p&gt;S2JDBCの説明で使われてた例と比較すると、ActsAsFluentedの使い方は以下のとおりです。&lt;/p&gt;
&lt;p&gt;S2JDBC&lt;br /&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nx&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Employee&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;results&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;jdbcManager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Employee&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                             &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;department&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                             &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;where&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;id in (? , ?)&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                             &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;orderBy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                             &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;getResultList&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nx&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Employee&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;results&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;jdbcManager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Employee&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
                             &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;department&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
                             &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;where&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;id in (? , ?)&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
                             &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;orderBy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
                             &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;getResultList&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/div&gt;&lt;/notextile&gt;&lt;/p&gt;
&lt;p&gt;ActsAsFluented&lt;br /&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Employee&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;with_query&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:all&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;join&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:department&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;where&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;employees.id IN (?, ?)&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;order_by&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Employee&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;with_query&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:all&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;br /&gt;
  &lt;span class=&quot;n&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;join&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:department&lt;/span&gt;&lt;br /&gt;
  &lt;span class=&quot;n&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;where&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;employees.id IN (?, ?)&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;order_by&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/div&gt;&lt;/notextile&gt;&lt;/p&gt;
&lt;p&gt;with_queryのoperatorパラメータでは、ActiveRecordのfindメソッドのように&lt;code&gt;:all&lt;/code&gt;か&lt;code&gt;:first&lt;/code&gt;を指定することで結果をリストで取得するか単一で取得するかを指定できます。デフォルトは&lt;code&gt;:all&lt;/code&gt;で省略可能です。また、ブロック内ではクエリをビルドしていくのですが、上の例のようにメソッドチェインでもDSLライクでもお好みで書くことが出来ます。&lt;/p&gt;
&lt;p&gt;この説明からも判るとおり、実装はActiveRecordのfindメソッドに一皮かぶせただけなので、Railsを使っている方であればクエリの組み立て方は容易に想像がつくと思います。コードも40行もないので、もし使うのであれば一通り読んでからお使いください。&lt;/p&gt;
&lt;p&gt;注意するポイントとしては、ActsAsFluented::QueryのjoinメソッドではActiveRecordのfindオプションの:includeを使って関連モデルを含めてロードします。同じクラスにjoinsメソッドもあるので紛らわしいです。あと、このActsAsFluented::Query#joinを使って関連モデルをロードした場合には、テーブル間で同じ名前のフィールドがあるとフィールド名だけではどちらか識別出来なくなるので、上記の例の用に、&lt;code&gt;&quot;employees.id IN (?, ?)&quot;&lt;/code&gt;とテーブル名を指定する必要があります。フィールド名だけで一意に識別できるのであればテーブル名は不要です。&lt;/p&gt;
&lt;h2&gt;ActsAsFluentedのメリットは&lt;/h2&gt;
&lt;p&gt;前述したとおり、書いた本人が使おうと思っていないぐらいメリットは感じられないのですが、しいてあげれば、&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;メソッド化した方が、打ち間違えた時にoptionsハッシュより発見しやすいかも&lt;/li&gt;
	&lt;li&gt;よりSQLに近い書き方ができるようになる&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;といったところでしょうか。メソッド化することによりIDEなどでコード補完が効くようになるS2JDBCに比べると全然アピールしませんね。何か他に付加価値をつけることができれば、正式にプラグインとして開発したいのですが思いつきません。&lt;/p&gt;
&lt;p&gt;ところで、ORマッパーの流行り廃りには僕自身何度も振り回されてきましたが、今はActiveRecordで満足しています。僕が関わるアプリケーションで実行速度がシビアに要求されない99%の場面では、これで充分です。&lt;/p&gt;
&lt;p&gt;でも、残り1%の場面は必ずおとずれるし、その1%にほとんどの労力が割かれた苦い経験もあるので、最後に将来に備えて自分なりに考えた各パターンの使いどころをまとめてみました。&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;「プログラマーなんかにSQLは触らせねぇ」というDBAがいる場合は名前付きクエリで外出し&lt;/li&gt;
	&lt;li&gt;HibernateのQueryインターフェイスは詳細検索のような動的クエリを組み立てるのに便利&lt;/li&gt;
	&lt;li&gt;フレームワークに不慣れな開発者をIDEの機能でサポートしたい場合は「流れるようなインターフェイス」&lt;/li&gt;
	&lt;li&gt;でも、やっぱりActiveRecord&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;ということで、今日も find, save &amp;amp; destroy.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>rake test:javascriptsでファイルやブラウザを指定する</title>
   <link href="http://blog.airs.co.jp/2007/10/11/rake-test-javascripts%E3%81%A6%E3%82%99%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%84%E3%83%95%E3%82%99%E3%83%A9%E3%82%A6%E3%82%B5%E3%82%99%E3%82%92%E6%8C%87%E5%AE%9A%E3%81%99%E3%82%8B.html"/>
   <updated>2007-10-11T06:05:00+09:00</updated>
   <id>/2007/10/11/rake-test-javascripts%E3%81%A6%E3%82%99%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%84%E3%83%95%E3%82%99%E3%83%A9%E3%82%A6%E3%82%B5%E3%82%99%E3%82%92%E6%8C%87%E5%AE%9A%E3%81%99%E3%82%8B.html</id>
   <content type="html">&lt;p&gt;インターンの増田です。&lt;/p&gt;
&lt;p&gt;Railsの&amp;quot;JavaScript Testプラグイン&amp;quot;:http://dev.rubyonrails.com/svn/rails/plugins/javascript_test/ に付属しているrakeタスク(test:javascripts)は&lt;br /&gt;
テストするファイルやブラウザを指定することができません。&lt;/p&gt;
&lt;p&gt;これではテストと実装を交互に繰り返しているときに関係ないテストまですべてのブラウザで実行されてしまってやっかいなので、rakeタスクを書き直してみました。&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;desc&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;Run tests for JavaScripts&amp;quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;task&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;test:javascripts&amp;#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:environment&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;no&quot;&gt;JavaScriptTest&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Runner&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; 
    
    &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mount&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;RAILS_ROOT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mount&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;/test&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;RAILS_ROOT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;/test&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mount&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;/test/javascript/assets&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;RAILS_ROOT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;/vendor/plugins/javascript_test/assets&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;no&quot;&gt;Dir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;glob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;ENV&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;TEST&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;test/javascript/*_test.html&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;basename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;.html&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gsub&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/_test/&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt; 

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ENV&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;BROWSER&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;ENV&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;BROWSER&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;to_sym&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:safari&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:firefox&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:ie&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:konqueror&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt; 
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt; 
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;     
&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;これに置き換えると、以下のようにコンパクトにテストできます。&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;
rake test:javascripts TEST=test/javascript/foo_test.html BROWSER=firefox
&lt;/code&gt;
&lt;/pre&gt;</content>
 </entry>
 
</feed>
