<?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/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>imishin.com &#187; ruby</title>
	<atom:link href="http://blog.imishin.com/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.imishin.com</link>
	<description></description>
	<lastBuildDate>Thu, 05 May 2011 16:30:31 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.imishin.com/tag/ruby/feed/" />
		<item>
		<title>ActionMailerJa の不具合を修正しました</title>
		<link>http://blog.imishin.com/2009/08/18/actionmailer-ja-%e3%81%ae%e4%b8%8d%e5%85%b7%e5%90%88%e3%82%92%e4%bf%ae%e6%ad%a3%e3%81%97%e3%81%be%e3%81%97%e3%81%9f/</link>
		<comments>http://blog.imishin.com/2009/08/18/actionmailer-ja-%e3%81%ae%e4%b8%8d%e5%85%b7%e5%90%88%e3%82%92%e4%bf%ae%e6%ad%a3%e3%81%97%e3%81%be%e3%81%97%e3%81%9f/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 03:04:55 +0000</pubDate>
		<dc:creator>kusakari</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>
		<category><![CDATA[ActionMailer]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.imishin.com/?p=750</guid>
		<description><![CDATA[しばらく放置気味だった ActionMailerJa の既知の不具合を修正しました。 修正内容は次の通り。 html メールの日本語が文字化けする不具合の修正。 添付ファイル付きメールの日本語が文字化けする不具合の修正。 [...]]]></description>
			<content:encoded><![CDATA[<p>しばらく放置気味だった <a title="ActionMailerJa" href="http://blog.imishin.com/projects/ruby/actionmailerja/">ActionMailerJa</a> の既知の不具合を修正しました。</p>
<p>修正内容は次の通り。</p>
<ul>
<li>html メールの日本語が文字化けする不具合の修正。</li>
<li>添付ファイル付きメールの日本語が文字化けする不具合の修正。</li>
<li>「～」が文字化けする不具合の修正。</li>
</ul>
<p>「～」の文字化けについては <a title="beyond さん" href="http://github.com/beyond/" target="_blank">beyond</a> さんに修正頂きました。ありがとうございます！</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.imishin.com/2009/08/18/actionmailer-ja-%e3%81%ae%e4%b8%8d%e5%85%b7%e5%90%88%e3%82%92%e4%bf%ae%e6%ad%a3%e3%81%97%e3%81%be%e3%81%97%e3%81%9f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.imishin.com/2009/08/18/actionmailer-ja-%e3%81%ae%e4%b8%8d%e5%85%b7%e5%90%88%e3%82%92%e4%bf%ae%e6%ad%a3%e3%81%97%e3%81%be%e3%81%97%e3%81%9f/" />
	</item>
		<item>
		<title>ActionMailerJa をバージョンアップしました</title>
		<link>http://blog.imishin.com/2009/04/28/actionmailer-ja-for-redmine-with-rails-2-2-2/</link>
		<comments>http://blog.imishin.com/2009/04/28/actionmailer-ja-for-redmine-with-rails-2-2-2/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 12:19:58 +0000</pubDate>
		<dc:creator>kusakari</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>
		<category><![CDATA[ActionMailer]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.imishin.com/?p=406</guid>
		<description><![CDATA[ActionMailer に日本語対応と携帯テンプレート振り分け機能を追加するプラグイン ActionMailerJa をバージョンアップしました。 といっても、Redmine + Rails 2.2.2 で Actio [...]]]></description>
			<content:encoded><![CDATA[<p>ActionMailer に日本語対応と携帯テンプレート振り分け機能を追加するプラグイン <a href="http://github.com/kusakari/actionmailer_ja/tree/master" target="_blank">ActionMailerJa</a> をバージョンアップしました。</p>
<p>といっても、Redmine + Rails 2.2.2 で <a href="http://github.com/kusakari/actionmailer_ja/tree/master" target="_blank">ActionMailerJa</a> を使うと日本語が文字化けする問題を　<a href="http://github.com/knu/" target="_blank">knu</a> さんが修正してくれたものを取り込んだだけです。</p>
<p><a href="http://github.com/knu/" target="_blank">knu</a> さんありがとうございます！</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.imishin.com/2009/04/28/actionmailer-ja-for-redmine-with-rails-2-2-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.imishin.com/2009/04/28/actionmailer-ja-for-redmine-with-rails-2-2-2/" />
	</item>
		<item>
		<title>valid_attributes プラグインを Rails 2.2 に対応しました</title>
		<link>http://blog.imishin.com/2009/03/19/valid_attributes-for-rails-2-2/</link>
		<comments>http://blog.imishin.com/2009/03/19/valid_attributes-for-rails-2-2/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 10:46:43 +0000</pubDate>
		<dc:creator>kusakari</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[RubyOnRails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.imishin.com/?p=374</guid>
		<description><![CDATA[最近、Rails 2.3 がリリースされたというのに、今さら valid_attributes プラグインを Rails 2.2 に対応しました。 kusakari&#8217;s valid_attributes at [...]]]></description>
			<content:encoded><![CDATA[<p>最近、Rails 2.3 がリリースされたというのに、今さら valid_attributes プラグインを Rails 2.2 に対応しました。</p>
<p><a href="http://github.com/kusakari/valid_attributes/tree/master" target="_blank">kusakari&#8217;s valid_attributes at master &#8211; GitHub</a></p>
<p>最近は iPhone アプリと Rails アプリを同時進行という感じです。</p>
<p>特に iPhone 関係はブログに書きたいことも多いのですが、さすがにアプリをリリースするまでは書けないですね…。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.imishin.com/2009/03/19/valid_attributes-for-rails-2-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.imishin.com/2009/03/19/valid_attributes-for-rails-2-2/" />
	</item>
		<item>
		<title>ActionMailerJa を Rails 2.2 に対応しました</title>
		<link>http://blog.imishin.com/2009/02/25/actionmailerja-for-rails2-2/</link>
		<comments>http://blog.imishin.com/2009/02/25/actionmailerja-for-rails2-2/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 11:47:29 +0000</pubDate>
		<dc:creator>kusakari</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.imishin.com/?p=365</guid>
		<description><![CDATA[ActionMailer に日本語対応と携帯テンプレート振り分け機能を追加するプラグイン ActionMailerJa を Rails 2.2 に対応しました。 Rails 2.2 以降では ActionMailer で [...]]]></description>
			<content:encoded><![CDATA[<p>ActionMailer に日本語対応と携帯テンプレート振り分け機能を追加するプラグイン ActionMailerJa を Rails 2.2 に対応しました。</p>
<p>Rails 2.2 以降では ActionMailer でも layout が使えるようになったので、layout ファイルの携帯振り分け機能を実装しました。</p>
<ul>
<li><a title="ActionMailerJa" href="/products/ruby/actionmailerja/" target="_blank">ActionMailerJa</a></li>
</ul>
<h3>携帯振り分け機能について</h3>
<p>携帯振り分けのファイル形式が、jpmobile 形式だと同じフォルダに大量にファイルができてしまうので、</p>
<p>views/action/mobile/ 以下とかにする方がわかりやすくて良い気がしてきました。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.imishin.com/2009/02/25/actionmailerja-for-rails2-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.imishin.com/2009/02/25/actionmailerja-for-rails2-2/" />
	</item>
		<item>
		<title>redirect_to :back は DoCoMo 携帯では使えない</title>
		<link>http://blog.imishin.com/2009/01/10/redirect_to-back-jpmobile/</link>
		<comments>http://blog.imishin.com/2009/01/10/redirect_to-back-jpmobile/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 04:29:14 +0000</pubDate>
		<dc:creator>kusakari</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.imishin.com/?p=337</guid>
		<description><![CDATA[rails は 以下のようにすると直前のページに戻ることができます。 redirect_to :back このリダイレクト先は環境変数 HTTP_REFERER の値が使われるのですが、 DoCoMo の携帯は Refe [...]]]></description>
			<content:encoded><![CDATA[<p>rails は 以下のようにすると直前のページに戻ることができます。</p>
<pre name="code" class="ruby">
redirect_to :back</pre>
<p>このリダイレクト先は環境変数 HTTP_REFERER の値が使われるのですが、</p>
<p>DoCoMo の携帯は Referrer を送出しないため、この値が取れません。</p>
<p>ではどうなるかというと、以下のようにエラーとなってしまいます。</p>
<pre name="code" class="ruby">
ActionController::RedirectBackError (No HTTP_REFERER was set in the request to this action, so redirect_to :back could not be called successfully. If this is a test, make sure to specify request.env["HTTP_REFERER"].):
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/base.rb:1066:in `redirect_to'
    /app/controllers/teams_controller.rb:47:in `join'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/base.rb:1166:in `send'
（省略）</pre>
<p>ということで、携帯ページでは redirect_to :back は使わないようにするか、</p>
<p>DoCoMo の場合だけ、別処理にした方が良さそうです。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.imishin.com/2009/01/10/redirect_to-back-jpmobile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.imishin.com/2009/01/10/redirect_to-back-jpmobile/" />
	</item>
		<item>
		<title>Rails 2.2 の i18n を使ってみた</title>
		<link>http://blog.imishin.com/2009/01/09/rails-2-2-i18n/</link>
		<comments>http://blog.imishin.com/2009/01/09/rails-2-2-i18n/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 08:49:32 +0000</pubDate>
		<dc:creator>kusakari</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.imishin.com/?p=330</guid>
		<description><![CDATA[Rails 2.2.2 で i18n を使ってみました。 前評判はイマイチだったので、どんな感じなのかなと思っていたけど、個人的には GetText より好きです。 手順としてはプロジェクトを作成して、scaffold  [...]]]></description>
			<content:encoded><![CDATA[<p>Rails 2.2.2 で i18n を使ってみました。</p>
<p>前評判はイマイチだったので、どんな感じなのかなと思っていたけど、個人的には GetText より好きです。</p>
<p><span id="more-330"></span></p>
<p>手順としてはプロジェクトを作成して、scaffold を実行した後、以下を実行します。</p>
<pre name="code" class="ruby">gem so -a http://gems.github.com
gem install amatsuda-i18n_generators
ruby script/generate i18n ja</pre>
<p>ただ、これだけでは、一部問題がありエラーメッセージが日本語化されないようです。（amatsuda-i18n_generators v0.4）</p>
<p>ということで、生成後の yml を3行消します。</p>
<h3>config/locales/ja.yml</h3>
<pre name="code" class="ruby">ja:
（省略）
  activerecord:
    errors:
      template:
        header:
          one:   "{{model}}にエラーが発生しました。"
          other: "{{model}}に{{count}}つのエラーが発生しました。"
-  activerecord:
-    errors:
-      template:
        body: "次の項目を確認してください。"

      messages:
（省略）</pre>
<p>
これで日本語化できました。簡単ですね。
</p>
<h3>label の日本語化</h3>
<p>これだけでは label は日本語化されないみたいなので、label の日本語化を作ってみた。<br />
config/initializers/libs.rb</p>
<pre name="code" class="ruby">
require 'active_record_helper'
</pre>
<p>lib/active_record_helper.rb</p>
<pre name="code" class="ruby">
module ActionView
  module Helpers
    module FormHelper
      def label_with_ja(object_name, method, text = nil, options = {})
        if text.nil?
          text = I18n.t(method, :default => method, :scope => [:activerecord, :attributes, object_name])
        end
        label_without_ja(object_name, method, text, options)
      end
      alias_method_chain :label, :ja  #:nodoc:
    end
  end
end
</pre>
<p>これで label も translation_ja.yml で指定した attributes 名が表示されます。</p>
<h3>参考</h3>
<ul>
<li><a href="http://blog.dio.jp/2008/11/22/japanizing-rails-2-2-by-i18n-generators" target="_blank">Close to the EDGE Rails 2.2の I18nによる日本語化を最も簡単に行う方法</a></li>
<li><a href="http://ukstudio.jp/2008/11/26/rails_22_i18n/" target="_blank">UK STUDIO &#8211; Rails2.2のi18n(国際化)を簡単に試してみた</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.imishin.com/2009/01/09/rails-2-2-i18n/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.imishin.com/2009/01/09/rails-2-2-i18n/" />
	</item>
		<item>
		<title>RailsJa プラグインを label に対応＆ jpmobile を named route に対応</title>
		<link>http://blog.imishin.com/2008/12/13/rails-ja-and-jpmobile-versionup/</link>
		<comments>http://blog.imishin.com/2008/12/13/rails-ja-and-jpmobile-versionup/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 17:46:29 +0000</pubDate>
		<dc:creator>kusakari</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.imishin.com/?p=306</guid>
		<description><![CDATA[rails 2.2 が i18n 対応したので、RailsJa プラグインの必要性は Rails 2.1 系までだなと思いつつも、 「Destiny Run」開発中に label がローカライズされないことに気づいて、機 [...]]]></description>
			<content:encoded><![CDATA[<p>rails 2.2 が i18n 対応したので、RailsJa プラグインの必要性は Rails 2.1 系までだなと思いつつも、</p>
<p>「<a title="Destiny Run" href="http://destinyrun.com/" target="_blank">Destiny Run</a>」開発中に label がローカライズされないことに気づいて、機能追加したものを Git にコミットしました。</p>
<h3>RailsJa</h3>
<p><a title="RailsJa" href="http://github.com/kusakari/rails-ja/tree/master" target="_blank">http://github.com/kusakari/rails-ja/tree/master</a></p>
<p>ついでに、jpmobile で named route が使えない問題も修正して、pull request してみました。</p>
<p><span style="text-decoration: line-through;">急ぎで jpmobile で named route を使い方は以下からどうぞ</span>。</p>
<h3><span style="text-decoration: line-through;">jpmobile</span></h3>
<p><span style="text-decoration: line-through;"><a title="jpmobile" href="http://github.com/kusakari/jpmobile/tree/master" target="_blank">http://github.com/kusakari/jpmobile/tree/master</a></span></p>
<p>本家に取り込んで頂けました。（2008/12/16）</p>
<p>rails 2.2 の i18n な機能はまだ試せてないので、そのうち試したいな。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.imishin.com/2008/12/13/rails-ja-and-jpmobile-versionup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.imishin.com/2008/12/13/rails-ja-and-jpmobile-versionup/" />
	</item>
		<item>
		<title>「Destiny Run」をリリースしました</title>
		<link>http://blog.imishin.com/2008/12/12/destinyrun-release/</link>
		<comments>http://blog.imishin.com/2008/12/12/destinyrun-release/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 16:54:51 +0000</pubDate>
		<dc:creator>kusakari</dc:creator>
				<category><![CDATA[Works]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://blog.imishin.com/?p=271</guid>
		<description><![CDATA[10月からお手伝いしていたサービス「Destiny Run」が昨日リリースされました。 「Destiny Run」は、いわゆるテーマパーク待ち時間共有サービスです。 機能的にはディズニーランド、ディズニーシー、ユニバーサ [...]]]></description>
			<content:encoded><![CDATA[<p>10月からお手伝いしていたサービス「<a title="Destiny Run" href="http://destinyrun.com/" target="_blank">Destiny Run</a>」が昨日リリースされました。</p>
<p><a href="http://blog.imishin.com/wp-content/uploads/2008/12/btm.jpg" target="_blank"><img class="alignleft size-medium wp-image-272" title="btm" src="http://blog.imishin.com/wp-content/uploads/2008/12/btm-113x300.jpg" alt="" width="118" height="313" /></a></p>
<p><a href="http://blog.imishin.com/wp-content/uploads/2008/12/destinyrun.jpg" target="_blank"><img class="size-medium wp-image-273 alignleft" title="destinyrun" src="http://blog.imishin.com/wp-content/uploads/2008/12/destinyrun-131x299.jpg" alt="" width="115" height="263" /></a></p>
<p>「<a title="Destiny Run" href="http://destinyrun.com/" target="_blank">Destiny Run</a>」は、いわゆるテーマパーク待ち時間共有サービスです。</p>
<p>機能的にはディズニーランド、ディズニーシー、ユニバーサルスタジオジャパンの、</p>
<p>アトラクションの待ち時間、ファストパスの待ち時間を見たり、入場施設、取得したファストパスの登録（次に取得できる時間の表示も！）ができるます。</p>
<p>また、現在地から近いアトラクションを探す機能や、クチコミ登録・閲覧機能、</p>
<p>グループを登録しての、グループメンバーの状況を見る機能、近い位置にいるメンバー情報を見る機能、一番近いメンバーへの距離を表示する機能などがあります。</p>
<p><span id="more-271"></span></p>
<p>Ruby on Rails で構築されており、主なプラグインとしては以下のものを利用しています。</p>
<ul>
<li>restful-authentication</li>
<li>jpmobile</li>
<li>google static maps plugin （このサービスのために開発）</li>
</ul>
<p>plugin 開発を含め開発開始からデータ登録、インストールなど含め、オープンまで約10日間で開発しました。</p>
<p>いわゆる CGM サービスなので多くの人に便利に使って頂いて盛り上がればいいなと思います。</p>
<p>slicehost 初めて使ったのですが、使いやすくて良いですね。</p>
<p>256MBでも、十分に rails が動くし、ネットワークも思ったより遅くないので自分でも借りてみようかと思いました。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.imishin.com/2008/12/12/destinyrun-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.imishin.com/2008/12/12/destinyrun-release/" />
	</item>
		<item>
		<title>Ruby と JavaScript を基本から学び直す</title>
		<link>http://blog.imishin.com/2008/10/17/study-ruby-and-javascript/</link>
		<comments>http://blog.imishin.com/2008/10/17/study-ruby-and-javascript/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 16:01:58 +0000</pubDate>
		<dc:creator>kusakari</dc:creator>
				<category><![CDATA[Diary]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.imishin.com/?p=247</guid>
		<description><![CDATA[せっかくフリーの日が一日できたこともあり、最近 Ruby と JavaScript を基本から学び直しています。 Ruby は『プログラミング Ruby 第二版 言語編』、JavaScript は『初めての JavaSc [...]]]></description>
			<content:encoded><![CDATA[<p>せっかくフリーの日が一日できたこともあり、最近 Ruby と JavaScript を基本から学び直しています。</p>
<p>Ruby は『プログラミング Ruby 第二版 言語編』、JavaScript は『初めての JavaScript』を購入して勉強しています。<br />
<br/></p>
<p>今さら『初めての JavaScript』はないかなぁ（使えなければ弟にあげればいいや）と思いつつ購入したのですが、</p>
<p>案外知らないことも多くて新鮮です。また、プログラム入門用にもすごくいい書籍だと思いました。<br />
<br/></p>
<p>僕自身、大学で学んだ C と社会人になってから仕事の都合で覚えた Java 以外は基本からじっくりやったことがなかったので、</p>
<p>Ruby と JavaScript もこの機会にしっかり基本固めをしようと思います。</p>
<p><iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=discovery00b-22&#038;o=9&#038;p=8&#038;l=as1&#038;asins=4274066428&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
<p><iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=discovery00b-22&#038;o=9&#038;p=8&#038;l=as1&#038;asins=4873113229&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.imishin.com/2008/10/17/study-ruby-and-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.imishin.com/2008/10/17/study-ruby-and-javascript/" />
	</item>
		<item>
		<title>restful-authentication プラグインを使ってログインアプリケーション作る（2）</title>
		<link>http://blog.imishin.com/2008/10/07/rails-with-restful-authentication-2/</link>
		<comments>http://blog.imishin.com/2008/10/07/rails-with-restful-authentication-2/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 02:10:37 +0000</pubDate>
		<dc:creator>kusakari</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>
		<category><![CDATA[restful-authentication]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.imishin.com/?p=238</guid>
		<description><![CDATA[前回作った todo アプリケーションにメールアドレス変更機能と、エラーメッセージ・メールの日本語化を追加します。 メールアドレス変更機能 change_email プラグインをインストールします。 ruby scrip [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.imishin.com/wp-content/uploads/2008/10/todos_ja.png"><img class="alignnone size-medium wp-image-242" title="todos_ja" src="http://blog.imishin.com/wp-content/uploads/2008/10/todos_ja-300x240.png" alt="" width="300" height="240" /></a></p>
<p><a href="http://blog.imishin.com/2008/09/14/rails-with-restful-authentication-on/">前回</a>作った todo アプリケーションにメールアドレス変更機能と、エラーメッセージ・メールの日本語化を追加します。</p>
<p><span id="more-238"></span></p>
<h3>メールアドレス変更機能</h3>
<p>change_email プラグインをインストールします。</p>
<pre class="prettyprint">ruby script/plugin install git://github.com/kusakari/change_email.git</pre>
<p>依存しているプラグインをインストールします。（valid-attributes）</p>
<pre class="prettyprint">ruby script/plugin install git://github.com/kusakari/valid_attributes.git</pre>
<p>メールアドレス保存用のコードを自動生成します。</p>
<pre class="prettyprint">ruby script/generate change_email email user</pre>
<p>migrate します。</p>
<pre class="prettyprint">rake db:migrate</pre>
<p>これで、以下の URL からメールアドレスを変更することができます。（ログイン後のみ）</p>
<blockquote><p>http://localhost:3000/change_email</p></blockquote>
<h3>エラーメッセージの日本語化</h3>
<p>RailsJa プラグインをインストールします。</p>
<pre class="prettyprint">ruby script/plugin install git://github.com/kusakari/rails-ja.git</pre>
<p>次に、app/models/todo.rb を変更します。</p>
<p>以下のようにして、@@humanized_attribute_names にアトリビュートごとの名称を設定します。</p>
<p>human_model_name は日本語モデル名を返すようにします。</p>
<pre class="prettyprint">class Todo &lt; ActiveRecord::Base
  validates_presence_of     :name
  validates_length_of       :name,    :within =&gt; 1..100
  class &lt;&lt; self
    @@humanized_attribute_names = {
      "name" =&gt; "タスク名",
    }
    def human_model_name
      "Todo"
    end
  end
end</pre>
<h3>メールの日本語対応</h3>
<p>ActionMailerJa プラグインはインストールするだけで日本語対応できる ActionMailer 拡張です。</p>
<pre class="prettyprint">ruby script/plugin install git://github.com/kusakari/actionmailer-ja.git</pre>
<p>ActionMailerJa はメールヘッダの Subject, From, Cc, Recipients の日本語化にも対応しているため、</p>
<p>例えば、app/models/user_mailer.rb の場合、以下のように変更します。</p>
<pre class="prettyprint">class UserMailer &lt; ActionMailer::Base
  def signup_notification(user)
    setup_email(user)
    @subject    += '新しいアカウントを有効にして下さい'

    @body[:url]  = "#{$SERVICE_URL}/activate/#{user.activation_code}"

  end

  def activation(user)
    setup_email(user)
    @subject    += 'アカウントが有効になりました'
    @body[:url]  = "#{$SERVICE_URL}"
  end

  protected
    def setup_email(user)
      @recipients  = "#{user.email}"
      @from        = "TODOアプリケーション &lt;#{$ADMIN_EMAIL}&gt;"
      @subject     = "[YOURSITE] "
      @sent_on     = Time.now
      @body[:user] = user
    end
end</pre>
<p>以上でメールアドレスの変更機能と、エラーメッセージ・メールの日本語対応ができました。</p>
<p>僕が現時点で Ruby on Rails を選択するのは、他のフレームワークでは、</p>
<p>ここまでの機能を同じくらい高速で汎用的に開発することはできないと思っているからです。</p>
<p>これはもちろん Ruby という言語によるものが大きいと思います。</p>
<p>ということで Ruby on Rails のメリットを最大限活かせるように、プラグインやジェネレータを積極的に作っていきたいと思います。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.imishin.com/2008/10/07/rails-with-restful-authentication-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.imishin.com/2008/10/07/rails-with-restful-authentication-2/" />
	</item>
	</channel>
</rss>

