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

<channel>
	<title>変なヤバいもんログ &#187; Rails</title>
	<atom:link href="http://ecpplus.net/weblog/tag/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://ecpplus.net/weblog</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sat, 17 Jul 2010 09:10:45 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Rails の Dynamic Scopes での delete_all は外部キーを NULL にするだけ</title>
		<link>http://ecpplus.net/weblog/rails-%e3%81%ae-dynamic-scopes-%e3%81%a7%e3%81%ae-delete_all-%e3%81%af%e5%a4%96%e9%83%a8%e3%82%ad%e3%83%bc%e3%82%92-null-%e3%81%ab%e3%81%99%e3%82%8b%e3%81%a0%e3%81%91/</link>
		<comments>http://ecpplus.net/weblog/rails-%e3%81%ae-dynamic-scopes-%e3%81%a7%e3%81%ae-delete_all-%e3%81%af%e5%a4%96%e9%83%a8%e3%82%ad%e3%83%bc%e3%82%92-null-%e3%81%ab%e3%81%99%e3%82%8b%e3%81%a0%e3%81%91/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 08:31:43 +0000</pubDate>
		<dc:creator>ちゅう</dc:creator>
				<category><![CDATA[1]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://ecpplus.net/weblog/?p=918</guid>
		<description><![CDATA[Shop has_many Items という状況のとき、とある shop が持っている items を、下記のように取ることが出来ます。それに対して、条件を設定することも出来ます。

&#62;&#62; @shop.it [...]]]></description>
			<content:encoded><![CDATA[<p>Shop has_many Items という状況のとき、とある shop が持っている items を、下記のように取ることが出来ます。それに対して、条件を設定することも出来ます。</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&gt;&gt;</span> <span style="color:#0066ff; font-weight:bold;">@shop</span>.<span style="color:#9900CC;">items</span> 
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>Item id:<span style="color:#006666;">21</span> shop_id: <span style="color:#006666;">1</span>, Item id: <span style="color:#006666;">22</span>, shop_id: <span style="color:#006666;">1</span>, ....<span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> <span style="color:#0066ff; font-weight:bold;">@shop</span>.<span style="color:#9900CC;">item</span>.<span style="color:#9900CC;">find_all_by_category</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;CPU&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> 
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>Item id:<span style="color:#006666;">23</span> shop_id: <span style="color:#006666;">1</span>, Item id: <span style="color:#006666;">26</span>, shop_id: <span style="color:#006666;">1</span>, ....<span style="color:#006600; font-weight:bold;">&#93;</span></pre></div></div>

<p>そこで、同様にとある Shop の Items を全部 delete_all にしようとしたのですが、DELETE されるのではなく、外部キーにNULLがセットされるという挙動になっています。</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&gt;&gt;</span> <span style="color:#0066ff; font-weight:bold;">@shop</span>.<span style="color:#9900CC;">items</span>.<span style="color:#9900CC;">delete_all</span></pre></div></div>

<p>とすると</p>

<div class="wp_syntax"><div class="code"><pre class="sql sql" style="font-family:monospace;">  Item <span style="color: #993333; font-weight: bold;">UPDATE</span> <span style="color: #66cc66;">&#40;</span>3<span style="color: #66cc66;">.</span>0ms<span style="color: #66cc66;">&#41;</span>   <span style="color: #993333; font-weight: bold;">UPDATE</span> <span style="color: #ff0000;">`items`</span> <span style="color: #993333; font-weight: bold;">SET</span> shop_id <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #66cc66;">&#40;</span>shop_id <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">AND</span> id <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">22</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">23</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">24</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">25</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">26</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>のようになります。</p>
<p>Rails の API を見ると</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># File vendor/rails/activerecord/lib/active_record/base.rb, line 897</span>
<span style="color:#006666;">897</span>:       <span style="color:#9966CC; font-weight:bold;">def</span> delete_all<span style="color:#006600; font-weight:bold;">&#40;</span>conditions = <span style="color:#0000FF; font-weight:bold;">nil</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#006666;">898</span>:         sql = <span style="color:#996600;">&quot;DELETE FROM #{quoted_table_name} &quot;</span>
<span style="color:#006666;">899</span>:         add_conditions!<span style="color:#006600; font-weight:bold;">&#40;</span>sql, conditions, scope<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:find</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#006666;">900</span>:         connection.<span style="color:#9900CC;">delete</span><span style="color:#006600; font-weight:bold;">&#40;</span>sql, <span style="color:#996600;">&quot;#{name} Delete all&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#006666;">901</span>:       <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>みたいになっているのですが、Dynamic Scopes はまた別のところで定義されているっぽいです。</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&gt;&gt;</span> <span style="color:#0066ff; font-weight:bold;">@shop</span>.<span style="color:#9900CC;">items</span>.<span style="color:#9900CC;">destroy_all</span></pre></div></div>

<p>としてみると、下記のように DELETE になりますが、SQL が発行されまくってるのでだめぽいです。そもそも destroy は、destroy をトリガーにしている各種処理をしてから DELETE が行われるので、そもそも delete とは意味合いが違うというので仕方ないです。</p>

<div class="wp_syntax"><div class="code"><pre class="sql sql" style="font-family:monospace;">Item Destroy <span style="color: #66cc66;">&#40;</span>3<span style="color: #66cc66;">.</span>0ms<span style="color: #66cc66;">&#41;</span>   <span style="color: #993333; font-weight: bold;">DELETE</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`items`</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #993333; font-weight: bold;">WHERE</span> id <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">21</span>
Item Destroy <span style="color: #66cc66;">&#40;</span>3<span style="color: #66cc66;">.</span>0ms<span style="color: #66cc66;">&#41;</span>   <span style="color: #993333; font-weight: bold;">DELETE</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`items`</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #993333; font-weight: bold;">WHERE</span> id <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">22</span>
Item Destroy <span style="color: #66cc66;">&#40;</span>3<span style="color: #66cc66;">.</span>0ms<span style="color: #66cc66;">&#41;</span>   <span style="color: #993333; font-weight: bold;">DELETE</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`items`</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #993333; font-weight: bold;">WHERE</span> id <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">23</span></pre></div></div>

<p>ふつうに Item.delete_all を呼ぶかなぁ</p>
]]></content:encoded>
			<wfw:commentRss>http://ecpplus.net/weblog/rails-%e3%81%ae-dynamic-scopes-%e3%81%a7%e3%81%ae-delete_all-%e3%81%af%e5%a4%96%e9%83%a8%e3%82%ad%e3%83%bc%e3%82%92-null-%e3%81%ab%e3%81%99%e3%82%8b%e3%81%a0%e3%81%91/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitterで食べたものを収集するbot作った</title>
		<link>http://ecpplus.net/weblog/twitter%e3%81%a7%e9%a3%9f%e3%81%b9%e3%81%9f%e3%82%82%e3%81%ae%e3%82%92%e5%8f%8e%e9%9b%86%e3%81%99%e3%82%8bbot%e4%bd%9c%e3%81%a3%e3%81%9f/</link>
		<comments>http://ecpplus.net/weblog/twitter%e3%81%a7%e9%a3%9f%e3%81%b9%e3%81%9f%e3%82%82%e3%81%ae%e3%82%92%e5%8f%8e%e9%9b%86%e3%81%99%e3%82%8bbot%e4%bd%9c%e3%81%a3%e3%81%9f/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 05:06:10 +0000</pubDate>
		<dc:creator>ちゅう</dc:creator>
				<category><![CDATA[1]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://ecpplus.net/weblog/?p=909</guid>
		<description><![CDATA[ようやく最近になって Twitter  いいなとか思ってるんですが、毎日自炊してると食べたものを記録したくなって、Twitter から自動的に拾ってくるようなアプリを作ってみた。
食べたものログ(仮) で、@eat_lo [...]]]></description>
			<content:encoded><![CDATA[<p>ようやく最近になって Twitter  いいなとか思ってるんですが、毎日自炊してると食べたものを記録したくなって、Twitter から自動的に拾ってくるようなアプリを作ってみた。</p>
<p><a href="http://eat.ecpplus.net/" target="_blank">食べたものログ(仮)</a> で、<a href="http://twitter.com/eat_log" target="_blank">@eat_log</a> をフォローすると、フォローしかえされてそこから収集が始まる感じです。それと、よく食べるものを集計して出すっていう機能もついてます。</p>
<p>実装に使ったのは、Rubyの <a href="http://twitter.rubyforge.org/" target="_blank">twitter</a> のライブラリと、<a href="http://developer.yahoo.co.jp/webapi/jlp/keyphrase/v1/extract.html" target="_blank">Yahoo! テキスト解析のキーフレーズ抽出</a> です。</p>
<p>Yahoo! テキスト解析は、JSONでレスポンス返してくれたりで、すごく簡単に使えます。<a href="http://twitter.rubyforge.org/twitter/">ruby twitter のドキュメント</a> を見れば、使い方はだいたい分かります。OAuth 認証も簡単でいいです。</p>
]]></content:encoded>
			<wfw:commentRss>http://ecpplus.net/weblog/twitter%e3%81%a7%e9%a3%9f%e3%81%b9%e3%81%9f%e3%82%82%e3%81%ae%e3%82%92%e5%8f%8e%e9%9b%86%e3%81%99%e3%82%8bbot%e4%bd%9c%e3%81%a3%e3%81%9f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActiveRecord の例外処理</title>
		<link>http://ecpplus.net/weblog/activerecord-%e3%81%ae%e4%be%8b%e5%a4%96%e5%87%a6%e7%90%86/</link>
		<comments>http://ecpplus.net/weblog/activerecord-%e3%81%ae%e4%be%8b%e5%a4%96%e5%87%a6%e7%90%86/#comments</comments>
		<pubDate>Wed, 20 May 2009 07:11:37 +0000</pubDate>
		<dc:creator>ちゅう</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://ecpplus.net/weblog/?p=806</guid>
		<description><![CDATA[RailsのActiveRecordで、save! とかすると保存に失敗したとき例外を投げてくれる。例えば、User.create!(params[:user]) とかして、失敗すると、ActiveRecord::Rec [...]]]></description>
			<content:encoded><![CDATA[<p>RailsのActiveRecordで、save! とかすると保存に失敗したとき例外を投げてくれる。例えば、User.create!(params[:user]) とかして、失敗すると、<code>ActiveRecord::RecordInvalid</code> を投げてくれるのだけど、エラーをどうやって取るのか調べたのでメモ。</p>
<p>よくある例で、ユーザが作れたら index へ遷移して、作れなかったら new で再入力させるという場合。</p>
<h3>createを使う場合</h3>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> create
  <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@user</span> = User.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:user</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">'ユーザ作成しました'</span>
    redirect_to <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'index'</span>
  <span style="color:#9966CC; font-weight:bold;">else</span>
    <span style="color:#008000; font-style:italic;"># ここでは、@user.errors でエラーが取れる</span>
    render <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'new'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<h3>create!を使う場合</h3>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> create
  <span style="color:#0066ff; font-weight:bold;">@user</span> = User.<span style="color:#9900CC;">create</span>!<span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:user</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">'ユーザ作成しました'</span>
  redirect_to <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'index'</span>
<span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::RecordInvalid</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> e
  <span style="color:#008000; font-style:italic;"># @user は nil になっているので、 @user.errors でエラーが取れない。</span>
  render <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'new'</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>としたとき、create! で例外が飛んでいるので、当然 @user は nil となってます。なので、rescue 句の中で @user.errors ではエラーが取れません。</p>
<p>調べたところ、e.record で、ActiveRecord の例外を発生させたインスタンスが取れるようです。</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> create
  <span style="color:#0066ff; font-weight:bold;">@user</span> = User.<span style="color:#9900CC;">create</span>!<span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:user</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">'ユーザ作成しました'</span>
  redirect_to <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'index'</span>
<span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::RecordInvalid</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> e
  <span style="color:#008000; font-style:italic;"># e.record に Userクラスのインスタンスが入ってる。</span>
  <span style="color:#0066ff; font-weight:bold;">@user</span> = e.<span style="color:#9900CC;">record</span>
  render <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'new'</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>たとえば、View内で</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">%</span>= error_messages_for <span style="color:#ff3333; font-weight:bold;">:user</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>とかしたい場合は、<code>@user = e.record</code> として置けばエラーが楽に表示出来て良い。</p>
]]></content:encoded>
			<wfw:commentRss>http://ecpplus.net/weblog/activerecord-%e3%81%ae%e4%be%8b%e5%a4%96%e5%87%a6%e7%90%86/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>rake notes</title>
		<link>http://ecpplus.net/weblog/rake-notes/</link>
		<comments>http://ecpplus.net/weblog/rake-notes/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 08:35:57 +0000</pubDate>
		<dc:creator>ちゅう</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://ecpplus.net/weblog/?p=777</guid>
		<description><![CDATA[プログラム中にコメントで

# TODO 退会のフローについてメール確認待ち 090420

とか書いたりするのだけど、Rails で使ってると rake で一覧を抽出出来る。

% rake notes
app/mod [...]]]></description>
			<content:encoded><![CDATA[<p>プログラム中にコメントで</p>

<div class="wp_syntax"><div class="code"><pre class="" style="font-family:monospace;"># TODO 退会のフローについてメール確認待ち 090420</pre></div></div>

<p>とか書いたりするのだけど、Rails で使ってると rake で一覧を抽出出来る。</p>

<div class="wp_syntax"><div class="code"><pre class="" style="font-family:monospace;">% rake notes
app/models/user.rb:
  * <span class="br0">&#91;</span><span style="">267</span><span class="br0">&#93;</span> <span class="br0">&#91;</span>TODO<span class="br0">&#93;</span> 退会のフローについてメール確認待ち 090420</pre></div></div>

<p>よく見てみたら、TODO以外も拾ってくれるようだ。</p>

<div class="wp_syntax"><div class="code"><pre class="" style="font-family:monospace;">% rake --tasks
rake notes                           # Enumerate all annotations
rake notes:fixme                     # Enumerate all FIXME annotations
rake notes:optimize                  # Enumerate all OPTIMIZE annotations
rake notes:todo                      # Enumerate all TODO annotations</pre></div></div>

<p>FIXME, OPTIMIZE, TODO とある。</p>
<p>どんな時に使うのか調べてみたら、</p>
<dl>
<dt>FIXME</dt>
<dd>修正の必要あり</dd>
<dt>OPTIMIZE</dt>
<dd>最適化の必要あり</dd>
<dt>TODO</dt>
<dd>TODOのメモ</dd>
</dl>
<p>みたいな感じに使えばいいらしい。</p>
<p>なるほど。</p>
]]></content:encoded>
			<wfw:commentRss>http://ecpplus.net/weblog/rake-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails2.2.2 で i18n 使ってみる</title>
		<link>http://ecpplus.net/weblog/rails222-%e3%81%a7-i18n-%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/</link>
		<comments>http://ecpplus.net/weblog/rails222-%e3%81%a7-i18n-%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 02:32:09 +0000</pubDate>
		<dc:creator>ちゅう</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://ecpplus.net/weblog/?p=702</guid>
		<description><![CDATA[Rails2.2.2 で簡単に多言語化(ていっても日本語しかお世話にならなそうだけど)出来てすごい！

% sudo gem so -a http://gems.github.com
% sudo gem i amats [...]]]></description>
			<content:encoded><![CDATA[<p>Rails2.2.2 で簡単に多言語化(ていっても日本語しかお世話にならなそうだけど)出来てすごい！</p>

<div class="wp_syntax"><div class="code"><pre class="" style="font-family:monospace;">% sudo gem so -a http://gems.github.com
% sudo gem i amatsuda-i18n_generators</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="" style="font-family:monospace;">% ./script/generate i18n ja</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="" style="font-family:monospace;">% vi config/locales/active_record_ja.yml</pre></div></div>

<p>すると、なかにごにょごにょ</p>

<div class="wp_syntax"><div class="code"><pre class="" style="font-family:monospace;">ja:
  activerecord:
    models:
      user: 'ユーザ'
    attributes:
      user:
        name: '名前'
        email: 'メールアドレス'
....</pre></div></div>

<p>みたいな感じで書くと、ARのエラーとか日本語されてる。お手軽ぽ。</p>
]]></content:encoded>
			<wfw:commentRss>http://ecpplus.net/weblog/rails222-%e3%81%a7-i18n-%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
