<?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>Roman&#039;s tech blog &#187; i18n</title>
	<atom:link href="http://blog.gugl.org/archives/category/i18n/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.gugl.org</link>
	<description>ruby, perl and other stuff</description>
	<lastBuildDate>Thu, 17 Jun 2010 12:19:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>I18n support for validates_date_time</title>
		<link>http://blog.gugl.org/archives/77</link>
		<comments>http://blog.gugl.org/archives/77#comments</comments>
		<pubDate>Sun, 08 Feb 2009 10:39:29 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[i18n]]></category>

		<guid isPermaLink="false">http://blog.gugl.org/?p=77</guid>
		<description><![CDATA[This simple fix uses the fact, that if the second argument to the &#8216;add&#8217; method is a symbol, then a generate_message is called, which does all the voodoo of Rails 2.2 I18n. I tried to contact the original author to no avail, therefore I&#8217;ll post it here, hoping that if anyone needs it, it&#8217;ll surface [...]]]></description>
			<content:encoded><![CDATA[<p>This simple fix uses the fact, that if the second argument to the &#8216;add&#8217; method is a symbol, then a generate_message is called, which does all the voodoo of Rails 2.2 I18n.<br />
I tried to contact the original author to no avail, therefore I&#8217;ll post it here, hoping that if anyone needs it, it&#8217;ll surface on a Google search.<br />
The fix itself is quite simple:</p>

<div class="wp_syntax"><div class="code"><pre class="diff" style="font-family:monospace;">Index: lib/validates_date_time.rb
===================================================================
<span style="color: #888822;">--- lib/validates_date_time.rb  <span style="">&#40;</span>revision <span style="">403</span><span style="">&#41;</span></span>
<span style="color: #888822;">+++ lib/validates_date_time.rb  <span style="">&#40;</span>working copy<span style="">&#41;</span></span>
<span style="color: #440088;">@@ -<span style="">114</span>,<span style="">7</span> +<span style="">114</span>,<span style="">7</span> @@</span>
       if options<span style="">&#91;</span>:before<span style="">&#93;</span>
         options<span style="">&#91;</span>:before<span style="">&#93;</span>.each do |r|
           if r.value<span style="">&#40;</span>record<span style="">&#41;</span> and value &gt;= r.last_value
<span style="color: #991111;">-            record.errors.add<span style="">&#40;</span>attr_name, options<span style="">&#91;</span>:before_message<span style="">&#93;</span> % r<span style="">&#41;</span></span>
<span style="color: #00b000;">+            record.errors.add<span style="">&#40;</span>attr_name, :before, :default =&gt; options<span style="">&#91;</span>:before_message<span style="">&#93;</span> % r<span style="">&#41;</span></span>
             break
           end
         end
<span style="color: #440088;">@@ -<span style="">123</span>,<span style="">7</span> +<span style="">123</span>,<span style="">7</span> @@</span>
       if options<span style="">&#91;</span>:after<span style="">&#93;</span>
         options<span style="">&#91;</span>:after<span style="">&#93;</span>.each do |r|
           if r.value<span style="">&#40;</span>record<span style="">&#41;</span> and value &lt;= r.last_value
<span style="color: #991111;">-            record.errors.add<span style="">&#40;</span>attr_name, options<span style="">&#91;</span>:after_message<span style="">&#93;</span> % r<span style="">&#41;</span></span>
<span style="color: #00b000;">+            record.errors.add<span style="">&#40;</span>attr_name, :after, :default =&gt; options<span style="">&#91;</span>:after_message<span style="">&#93;</span> % r<span style="">&#41;</span></span>
             break
           end
         end</pre></div></div>

<p>I&#8217;ve a fork of the git-svn mirror here:<br />
<a href='http://github.com/romanbsd/validates_date_time/tree/master'>http://github.com/romanbsd/validates_date_time/tree/master</a></p>
<p>Then, for using it, you&#8217;ll just need to have the following path in your locale yml files (for example):</p>
<pre>
  activerecord:
    errors:
      models:
        user:
          attributes:
            birth_date:
              before: 'is wrong'
              after: 'is wrong'
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.gugl.org/archives/77/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
