<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Benjamin Oakes</title>
	
	<link>http://www.benjaminoakes.com</link>
	<description />
	<lastBuildDate>Wed, 18 Apr 2012 16:58:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/BenjaminOakes" /><feedburner:info uri="benjaminoakes" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>My thoughts on GitHub for Mac</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/4s68kW1PIoA/</link>
		<comments>http://www.benjaminoakes.com/2012/04/17/my-thoughts-on-github-for-mac/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 13:14:22 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[GitHub]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=147</guid>
		<description><![CDATA[I recently wrote a comment for &#8220;GitHub for Mac: Easier Updates&#8221;. Since it sums up my feelings on several subjects (including my feelings about the future of OS X), I thought I should repost it here. Maybe more people use this than I realize, but I have to say I still don&#8217;t get this. As [...]]]></description>
			<content:encoded><![CDATA[<p>I recently wrote a comment for <a href="https://github.com/blog/1102-github-for-mac-easier-updates">&#8220;GitHub for Mac: Easier Updates&#8221;</a>.  Since it sums up my feelings on several subjects (including my feelings about the future of OS X), I thought I should repost it here.</p>
<blockquote>
<p>Maybe more people use this than I realize, but I have to say I still don&#8217;t get this.</p>
<p>As a web developer myself, I tend to support web-based apps; perhaps the Mac app is popular with Mac/iOS developers?  More can be done from the web interface, which works on Windows, Mac, and Linux.  (Plus, the web UI always stays up to date.)  The only additional feature this really seems to add is a &#8220;sync&#8221; button locally.  Perhaps I&#8217;m missing something, but this is all that I take away from the feature list and what I&#8217;ve used of it.</p>
<p>To be honest, the direction in which OS X Mountain Lion is headed doesn&#8217;t thrill me.  Since I&#8217;m contemplating a move from OS X back to Linux, it&#8217;s disappointing to see an interface for this closed system even being worked on.  Such a huge amount of open-source projets are hosted on GitHub (including the <a href="https://github.com/torvalds/linux">Linux kernel</a> itself).  If I were to expect Linux support from anyone, it would be you guys.  I can understand that OS X is likely a large market for GitHub users, but I would wonder about the portability of this app&#8230;</p>
<p>This would be much more compelling if it were an open-source interface for <code>git</code> repos, but I could understand how that might not be in GitHub&#8217;s best interest.  (But imagine a GitHub tool built by the users, for the users&#8230;)  Maybe I&#8217;m more of a <code>git</code> power user than I realize, but without at least support for a remote other than <code>origin</code>, multiple operating systems, etc., I can&#8217;t say this is something I&#8217;ll ever use.  Making it open-source would be a bonus, although it seems unlikely at this point.</p>
<p>Maybe I&#8217;m just missing something, but other commenters here would seem to agree.</p>
</blockquote>
<p><b>Update:</b>  By the end of the day, they deleted not only this comment, but many others that cast an unfavorable light on GitHub for Mac.  (There was at least one other that had a function named <code>shallWeUseThisSoft</code>.)</p>
<p>In the interest of preservation, here are some other recently added comments that seem likely to be deleted:</p>
<p>From <a href="http://github.com/battlemidget">battlemidget</a>:</p>
<blockquote>
<pre><code>At GitHub, we think that sharing code should be as simple as possible.
That’s why we created GitHub for Mac.
</code></pre>
<p>Where is the source code for this client so others can port it?</p>
</blockquote>
<p>From <a href="http://github.com/GreatS">GreatS</a>:</p>
<blockquote>
<p>Please do <em>not</em> distribute through the mac app store and if possible do not use an apple developer id to authenticate your apps so that we don&#8217;t end up with an ecosystem fully controlled by apple (see the gatekeeper non sense they are going to introduce in mountain lion).</p>
</blockquote>
 <p><a href="http://www.benjaminoakes.com/?flattrss_redirect&amp;id=147&amp;md5=5902ace4b4d6c926ad1a4064053b7c4d" title="Flattr" target="_blank"><img src="http://www.benjaminoakes.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/4s68kW1PIoA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2012/04/17/my-thoughts-on-github-for-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=benjaminoakes&amp;url=http%3A%2F%2Fwww.benjaminoakes.com%2F2012%2F04%2F17%2Fmy-thoughts-on-github-for-mac%2F&amp;language=en_GB&amp;category=text&amp;title=My+thoughts+on+GitHub+for+Mac&amp;description=I+recently+wrote+a+comment+for+%26%238220%3BGitHub+for+Mac%3A+Easier+Updates%26%238221%3B.+Since+it+sums+up+my+feelings+on+several+subjects+%28including+my+feelings+about+the+future+of+OS+X%29%2C+I...&amp;tags=blog%2Cruby%2Crails%2Cjavascript%2Csoftware+development%2Cgeek" type="text/html" />
	<feedburner:origLink>http://www.benjaminoakes.com/2012/04/17/my-thoughts-on-github-for-mac/</feedburner:origLink></item>
		<item>
		<title>Common configuration for production and staging</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/I4ln5oSGVsc/</link>
		<comments>http://www.benjaminoakes.com/2012/04/16/common-configuration-for-production-and-staging/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 15:21:07 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=145</guid>
		<description><![CDATA[Like many web apps, we typically have a need for a staging environment to test before we deploy to production. Combined with continuous deployment, it becomes much quicker and easier to find issues that would affect production by testing in this production-like environment. This staging environment needs to be as close as possible to production; [...]]]></description>
			<content:encoded><![CDATA[<p>Like many web apps, we typically have a need for a staging environment to test before we deploy to production.  Combined with continuous deployment, it becomes much quicker and easier to find issues that would affect production by testing in this production-like environment.</p>
<p>This staging environment needs to be as close as possible to production; ideally the only things that are different are the data and some integration points.  Having different behavior based on environment makes realistic testing difficult.  Different configuration based on environment can also be problematic.  In many ways, staging can be thought of as being based on production&#8230; but how does that work in pratice?</p>
<p>Rails doesn&#8217;t provide a built in idiom for a staging environment (the default environments are just &#8220;development&#8221;, &#8220;test&#8221;, and &#8220;production&#8221;), so many people have come up with their own way of managing the staging configuration problem.  Many times the reality is that <code>config/environments/staging.rb</code> is a copied and pasted version of <code>config/environments/production.rb</code> along with some minor adjustments.</p>
<p>That&#8217;s ugly.</p>
<p>Here&#8217;s a more elegant strategy that we&#8217;re trying out:</p>
<pre><code>
# File: config/environments/common.rb
OurApp::Application.configure do
  # Common configuration goes here

  # Example:
  config.foo_bar = false
end

# File: config/environments/staging.rb
require_relative './common'

OurApp::Application.configure do
  # Any staging-specific configuration goes here.
end

# File: config/environments/production.rb
require_relative './common'

OurApp::Application.configure do
  # Any production-specific configuration goes here.
end
</code></pre>
<p>This allows us to set a baseline &#8220;production&#8221; configuration, but still override settings as necessary.  It seems to reduce the amount of manual maintenance (&#8220;syncing&#8221;) of enviroments in the way we were hoping too, so we don&#8217;t accidentally let a configuration change go untested until a production deployment.</p>
<p>(Technical info: this was written against Ruby 1.9.2p180 and Rails 3.2.3.)</p>
 <p><a href="http://www.benjaminoakes.com/?flattrss_redirect&amp;id=145&amp;md5=03c0ee441878338942e528097356dc7f" title="Flattr" target="_blank"><img src="http://www.benjaminoakes.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/I4ln5oSGVsc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2012/04/16/common-configuration-for-production-and-staging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=benjaminoakes&amp;url=http%3A%2F%2Fwww.benjaminoakes.com%2F2012%2F04%2F16%2Fcommon-configuration-for-production-and-staging%2F&amp;language=en_GB&amp;category=text&amp;title=Common+configuration+for+production+and+staging&amp;description=Like+many+web+apps%2C+we+typically+have+a+need+for+a+staging+environment+to+test+before+we+deploy+to+production.+Combined+with+continuous+deployment%2C+it+becomes+much+quicker+and+easier...&amp;tags=blog%2Cruby%2Crails%2Cjavascript%2Csoftware+development%2Cgeek" type="text/html" />
	<feedburner:origLink>http://www.benjaminoakes.com/2012/04/16/common-configuration-for-production-and-staging/</feedburner:origLink></item>
		<item>
		<title>Test upcoming browsers automatically via jsTestDriver</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/QAtH6I-Vcpg/</link>
		<comments>http://www.benjaminoakes.com/2012/02/24/test-upcoming-browsers-automatically-via-jstestdriver/#comments</comments>
		<pubDate>Fri, 24 Feb 2012 16:40:00 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[GitHub]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=143</guid>
		<description><![CDATA[We&#8217;ve been using jsTestDriver (JSTD) along with the Jasmine BDD library via jasmine-jstd-adapter. We&#8217;re also using some glue code I wrote called jasmine-jstd-conf which writes a jsTestDriver config file based on jasmine.yml. Right now, we have some older, mostly-unused machines running a bunch of browsers attached to JSTD. While doing some maintenance today, I had [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve been using <a href="http://code.google.com/p/js-test-driver/">jsTestDriver</a> (JSTD) along with the <a href="http://pivotal.github.com/jasmine/">Jasmine</a> BDD library via <a href="https://github.com/ibolmo/jasmine-jstd-adapter">jasmine-jstd-adapter</a>.  We&#8217;re also using some glue code I wrote called <a href="https://github.com/hedgeyedev/jasmine-jstd-conf">jasmine-jstd-conf</a> which writes a jsTestDriver config file based on <code>jasmine.yml</code>.</p>
<p>Right now, we have some older, mostly-unused machines running a bunch of browsers attached to JSTD.  While doing some maintenance today, I had an interesting idea:  we need to support the browsers that are popular according to our analytics.  That typically means the current and previous version, except for IE, which we support 7.0+ (9.0 is current).</p>
<p>However, we also need to support the <strong>next</strong> version of any popular browser. &nbsp;Since Chrome and Firefox both have a beta channel of what is likey to be released as the next version, we can easily test whether any of our JavaScript will break in the new version of those browsers <em>before</em> they&#8217;re released and <em>before</em> a user runs into a problem we could have detected earlier.</p>
<p>So, we now have Chrome 16, 17 (current), and 18, along with Firefox 9, 10 (current), and 11.</p>
<p>Here&#8217;s some sample JSTD output from a Jasmine test suite we have:</p>
<pre><code>Chrome 16.0.912.77 Windows: Run 50 tests (Passed: 50; Fails: 0; Errors 0) (267.00 ms)
Chrome 17.0.963.56 Mac OS: Run 100 tests (Passed: 100; Fails: 0; Errors 0) (318.00 ms)
Chrome 17.0.963.56 Windows: Run 50 tests (Passed: 50; Fails: 0; Errors 0) (196.00 ms)
Chrome 18.0.1025.39 Mac OS: Run 50 tests (Passed: 50; Fails: 0; Errors 0) (209.00 ms)
Firefox 9.0.1 Mac OS: Run 50 tests (Passed: 50; Fails: 0; Errors 0) (681.00 ms)
Firefox 9.0.1 Windows: Run 50 tests (Passed: 49; Fails: 1; Errors 0) (1598.00 ms)
Firefox 10.0 Windows: Run 50 tests (Passed: 50; Fails: 0; Errors 0) (293.00 ms)
Firefox 10.0.2 Mac OS: Run 50 tests (Passed: 50; Fails: 0; Errors 0) (260.00 ms)
Firefox 11.0 Mac OS: Run 50 tests (Passed: 50; Fails: 0; Errors 0) (368.00 ms)
Microsoft Internet Explorer 7.0 Windows: Run 50 tests (Passed: 50; Fails: 0; Errors 0) (2749.00 ms)
Microsoft Internet Explorer 8.0 Windows: Run 50 tests (Passed: 50; Fails: 0; Errors 0) (2078.00 ms)
Microsoft Internet Explorer 9.0 Windows: Run 100 tests (Passed: 100; Fails: 0; Errors 0) (698.00 ms)
Safari 534.52.7 Mac OS: Run 50 tests (Passed: 50; Fails: 0; Errors 0) (1553.00 ms)
Safari 6533.18.5 iPhone OS: Run 50 tests (Passed: 50; Fails: 0; Errors 0) (184.00 ms)
</code></pre>
<p>With that many JavaScript implementations to support, writing automated tests only makes sense.</p>
<p>You might also be interested in the <a href="http://benjaminoakes.github.com/testing_toolbox/">Testing Toolbox slides</a> I presented at the <a href="http://www.meetup.com/newhavenrb/events/36030682/">NewHaven.rb October Lightning Talks</a>.</p>
 <p><a href="http://www.benjaminoakes.com/?flattrss_redirect&amp;id=143&amp;md5=387c85c9cd3fb2d08852e04e72673a1c" title="Flattr" target="_blank"><img src="http://www.benjaminoakes.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/QAtH6I-Vcpg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2012/02/24/test-upcoming-browsers-automatically-via-jstestdriver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=benjaminoakes&amp;url=http%3A%2F%2Fwww.benjaminoakes.com%2F2012%2F02%2F24%2Ftest-upcoming-browsers-automatically-via-jstestdriver%2F&amp;language=en_GB&amp;category=text&amp;title=Test+upcoming+browsers+automatically+via+jsTestDriver&amp;description=We%26%238217%3Bve+been+using+jsTestDriver+%28JSTD%29+along+with+the+Jasmine+BDD+library+via+jasmine-jstd-adapter.+We%26%238217%3Bre+also+using+some+glue+code+I+wrote+called+jasmine-jstd-conf+which+writes+a+jsTestDriver+config+file+based...&amp;tags=blog%2Cruby%2Crails%2Cjavascript%2Csoftware+development%2Cgeek" type="text/html" />
	<feedburner:origLink>http://www.benjaminoakes.com/2012/02/24/test-upcoming-browsers-automatically-via-jstestdriver/</feedburner:origLink></item>
		<item>
		<title>Filter params on Rails 3.1 when calling notify_airbrake</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/v5D_uoq3S6E/</link>
		<comments>http://www.benjaminoakes.com/2012/02/23/filter-params-on-rails-3-1-when-calling-notify_airbrake/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 22:16:45 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=141</guid>
		<description><![CDATA[<p>We recently noticed that Airbrake doesn't always filter our parameters.</p>

<p>I looked into the cases, and eventually narrowed it down to this:  an unhandled exception is filtered properly, but a notification made via <code>notify_airbrake</code> does not.</p>]]></description>
			<content:encoded><![CDATA[<p>From my recent <a href="https://github.com/airbrake/airbrake/pull/59">pull request on Airbrake</a>:</p>
<blockquote>
<p>We recently noticed that Airbrake doesn&#8217;t always filter our parameters.</p>
<p>I looked into the cases, and eventually narrowed it down to this:  an unhandled exception is filtered properly, but a notification made via <code>notify_airbrake</code> does not.</p>
<p>I traced the problem to</p>
<p><code>Airbrake::Rails::ControllerMethods#airbrake_filter_if_filtering</code>:</p>
<pre><code><span class="k">def airbrake_filter_if_filtering(hash)
  return hash if ! hash.is_a?(Hash)

  if respond_to?(:filter_parameters)
    filter_parameters(hash) rescue hash
  else
    hash
  end
end</code></pre>
<p>After doing some research, I found that <code>filter_parameters</code> is a <a href="https://github.com/rails/rails/blob/v2.1.2/actionpack/lib/action_controller/base.rb#L487">Rails 2</a> method that has since been replaced by <a href="http://stackoverflow.com/questions/6152388/manually-filter-parameters-in-rails">ActionDispatch::Http::ParameterFilter</a>.  There are other methods used in Airbrake are deprecated by Rails.  For example <a href="http://apidock.com/rails/ActionController/Base/filter_parameter_logging/class">filter_parameter_logging</a> (found in <code>test/catcher_test.rb</code>) disappeared after Rails 2.3.8.</p>
<p>I attempted to add a test for my changes, but couldn&#8217;t reproduce the problem using the available helpers in <code>test/catcher_test.rb</code>, although the problem clearly exists in our production use.  As near as I can tell <code>process_action_with_manual_notification</code> may not actually be testing in a realistic way;  there seem to be at least two ways that Airbrake filters parameters.  If I&#8217;m missing something, please point me in the right direction.</p>
<p>At any rate, the changes in this pull request fixes the problem when I tested on a staging environment.  Our app is using Ruby 1.9.2p180 and Rails 3.1.2 at the time of this writing.</p>
</blockquote>
 <p><a href="http://www.benjaminoakes.com/?flattrss_redirect&amp;id=141&amp;md5=b87de0d9a8c7550eb8e34311dcc6e89c" title="Flattr" target="_blank"><img src="http://www.benjaminoakes.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/v5D_uoq3S6E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2012/02/23/filter-params-on-rails-3-1-when-calling-notify_airbrake/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=benjaminoakes&amp;url=http%3A%2F%2Fwww.benjaminoakes.com%2F2012%2F02%2F23%2Ffilter-params-on-rails-3-1-when-calling-notify_airbrake%2F&amp;language=en_GB&amp;category=text&amp;title=Filter+params+on+Rails+3.1+when+calling+notify_airbrake&amp;description=From+my+recent+pull+request+on+Airbrake%3A+We+recently+noticed+that+Airbrake+doesn%26%238217%3Bt+always+filter+our+parameters.+I+looked+into+the+cases%2C+and+eventually+narrowed+it+down+to+this%3A+an...&amp;tags=blog%2Cruby%2Crails%2Cjavascript%2Csoftware+development%2Cgeek" type="text/html" />
	<feedburner:origLink>http://www.benjaminoakes.com/2012/02/23/filter-params-on-rails-3-1-when-calling-notify_airbrake/</feedburner:origLink></item>
		<item>
		<title>autoload in Ruby 1.8 and Rails</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/Q7MXgzbNa6s/</link>
		<comments>http://www.benjaminoakes.com/2011/12/01/autoload-in-ruby-1-8-libraries/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 13:54:47 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=140</guid>
		<description><![CDATA[Just a PSA from a recent Ruby discussion: Ruby&#8217;s autoload works fine if you&#8217;re using it in a gem that&#8217;s loaded once (and need to use it on Ruby 1.8, vs. require_relative in Ruby 1.9+), but if autoload is used in a collection of Ruby classes or modules in a folder that&#8217;s in the Rails [...]]]></description>
			<content:encoded><![CDATA[<p>Just a PSA from a recent Ruby discussion:</p>
<p>Ruby&#8217;s <code>autoload</code> works fine if you&#8217;re using it in a gem that&#8217;s loaded <b>once</b> (and need to use it on Ruby 1.8, vs. <code>require_relative</code> in Ruby 1.9+), but if <code>autoload</code> is used in a collection of Ruby classes or modules in a folder that&#8217;s in the Rails load path, then it&#8217;s probably not a good idea.  You&#8217;ll get unexpected reloading behavior, at a minimum.  That applies to submodules too, of course.</p>
<p>In general, you don&#8217;t want to mess with <code>$LOAD_PATH</code>, which was a fairly common practice in 1.8.  That&#8217;s largely gone away in 1.9 with the advent of <code>require_relative</code>, but many gems need to be backwards compatible.  In Ruby 1.8, you can always futz around with <code>__FILE__</code>, but that gets messy as well.</p>
 <p><a href="http://www.benjaminoakes.com/?flattrss_redirect&amp;id=140&amp;md5=69b5ba54caa9db5dfcd6df4f0b0bdf83" title="Flattr" target="_blank"><img src="http://www.benjaminoakes.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/Q7MXgzbNa6s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2011/12/01/autoload-in-ruby-1-8-libraries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=benjaminoakes&amp;url=http%3A%2F%2Fwww.benjaminoakes.com%2F2011%2F12%2F01%2Fautoload-in-ruby-1-8-libraries%2F&amp;language=en_GB&amp;category=text&amp;title=autoload+in+Ruby+1.8+and+Rails&amp;description=Just+a+PSA+from+a+recent+Ruby+discussion%3A+Ruby%26%238217%3Bs+autoload+works+fine+if+you%26%238217%3Bre+using+it+in+a+gem+that%26%238217%3Bs+loaded+once+%28and+need+to+use+it+on+Ruby+1.8%2C...&amp;tags=blog%2Cruby%2Crails%2Cjavascript%2Csoftware+development%2Cgeek" type="text/html" />
	<feedburner:origLink>http://www.benjaminoakes.com/2011/12/01/autoload-in-ruby-1-8-libraries/</feedburner:origLink></item>
		<item>
		<title>Blocking migration creation in Rails</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/1soMm_an8aA/</link>
		<comments>http://www.benjaminoakes.com/2011/11/29/blocking-migration-creation-in-rails/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 16:40:16 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=137</guid>
		<description><![CDATA[We have a project that accesses a shared database. To prevent problems (and confusion) we wanted to block the creation of migrations in the &#8220;secondary&#8221; applications so that there was one authoritative place for migrations to live. It&#8217;s easy to accomplish in a simple way. If you&#8217;ve never made any migrations in the secondary application, [...]]]></description>
			<content:encoded><![CDATA[<p>We have a project that accesses a shared database.  To prevent problems (and confusion) we wanted to block the creation of migrations in the &#8220;secondary&#8221; applications so that there was one authoritative place for migrations to live.</p>
<p>It&#8217;s easy to accomplish in a simple way.</p>
<p>If you&#8217;ve never made any migrations in the secondary application, just do this:</p>
<pre><code>$ echo "NOTE Please do not make migrations in this project.  They should all live in _primary app_." > db/migrate
</code></pre>
<p>That way, when you run <code>rails g migration foo</code>, you&#8217;ll get this:</p>
<pre><code>$ rails g migration foo
      invoke  active_record
      create    db/migrate/20111129162804_foo.rb
[...]/ruby-1.9.2-p180/lib/ruby/1.9.1/fileutils.rb:243:in `mkdir': File exists - [...]/db/migrate (Errno::EEXIST)
</code></pre>
<p>When you try to <code>cd</code> into that directory, you&#8217;ll get this:</p>
<pre><code>$ cd db/migrate
bash: cd: db/migrate: Not a directory
</code></pre>
<p>After you get over the initial &#8220;wha?&#8221; reaction, you&#8217;ll look at <code>db/migrate</code> and see the message:</p>
<pre><code>$ cat db/migrate
NOTE Please do not make migrations in this project.  They should all live in _primary app_.
</code></pre>
<p>Pretty nice, right?</p>
 <p><a href="http://www.benjaminoakes.com/?flattrss_redirect&amp;id=137&amp;md5=0a9a46bafe904d4ff5593f2dc4e95937" title="Flattr" target="_blank"><img src="http://www.benjaminoakes.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/1soMm_an8aA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2011/11/29/blocking-migration-creation-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=benjaminoakes&amp;url=http%3A%2F%2Fwww.benjaminoakes.com%2F2011%2F11%2F29%2Fblocking-migration-creation-in-rails%2F&amp;language=en_GB&amp;category=text&amp;title=Blocking+migration+creation+in+Rails&amp;description=We+have+a+project+that+accesses+a+shared+database.+To+prevent+problems+%28and+confusion%29+we+wanted+to+block+the+creation+of+migrations+in+the+%26%238220%3Bsecondary%26%238221%3B+applications+so+that+there+was...&amp;tags=blog%2Cruby%2Crails%2Cjavascript%2Csoftware+development%2Cgeek" type="text/html" />
	<feedburner:origLink>http://www.benjaminoakes.com/2011/11/29/blocking-migration-creation-in-rails/</feedburner:origLink></item>
		<item>
		<title>Using Heroku with an external MySQL database</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/vf9MzuiIRfM/</link>
		<comments>http://www.benjaminoakes.com/2011/11/21/using-heroku-with-an-external-mysql-database/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 20:33:10 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[contribution]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[external]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[heroku]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[oss]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=136</guid>
		<description><![CDATA[We recently had a need to use Heroku with an external MySQL database. Thankfully, there was already a gem that solved the problem. However, it didn&#8217;t have that much by the way of documentation, so I wrote this up and contributed it to the author. Also, I added X.509 support, which we required. NOTE: After [...]]]></description>
			<content:encoded><![CDATA[<p>We recently had a need to use Heroku with an external MySQL database.  Thankfully, there was already a <a href="https://github.com/nbudin/heroku_external_db">gem</a> that solved the problem.  However, it didn&#8217;t have that much by the way of documentation, so I wrote this up and contributed it to the author.  Also, I added X.509 support, which we required.</p>
<hr />
<p><b>NOTE:</b> After my pull requests are merged, you should look to <a href="https://github.com/nbudin/heroku_external_db">the main repository&#8217;s README</a> which has a copy of the below.</p>
<hr />
<h4>Example: MySQL with a CA Certificate</h4>
<p>In this example, we are setting up a connection to an external MySQL server using the default initializer.</p>
<p>What we have:</p>
<ul>
<li>
<p>A CA certificate called <tt>ca-cert.pem</tt></p>
</li>
<li>
<p>A database is available at mysql://username:password@server/dbname (where <tt>username</tt>, <tt>password</tt>, <tt>server</tt>, and <tt>dbname</tt> are the appropriate values for our server)</p>
</li>
<li>
<p>Other security, e.g. firewalls.  Please make sure to open the appropriate ports and grant the necessary access for your database to be available externally.  Further discussion is outside the scope of this document, but for accessing EC2, you might start at <a href="http://devcenter.heroku.com/articles/external-services">devcenter.heroku.com/articles/external-services</a>.</p>
</li>
</ul>
<p>First, we configure Heroku with the appropriate environment variables:</p>
<pre># You may have to specify the app name or remote name here via --app or --remote, respectively
heroku config:add EXTERNAL_DATABASE_CA='ca-cert.pem'
heroku config:add EXTERNAL_DATABASE_URL='mysql://username:password@server/dbname'</pre>
<p>By default, <tt>heroku_external_db</tt> looks for the CA cert in<br />
<tt>config/ca</tt>, so we need to commit it:</p>
<pre>mkdir -p config/ca
cp path/to/ca-cert.pem config/ca
git add config/ca
git commit -v # Using -v since we want to make sure the contents are what we expect (e.g. not a private key)</pre>
<p>Additionally, we need the <tt>mysql</tt> gem in our Gemfile since we are setting up a MySQL server:</p>
<pre>echo "gem 'mysql', '~&gt; 2.8.1'" &gt;&gt; Gemfile
bundle install # Need Gemfile.lock too</pre>
<p>Keep in mind that Heroku installs its own <tt>database.yml</tt> for Rails apps and we have to install <tt>pg</tt> as well.  Unfortunately, shared databases are mandatory (but are free).</p>
<pre>$ heroku addons:remove shared-database:5mb
-----&gt; Removing shared-database:5mb from our-app... failed
 !     Shared databases cannot be removed</pre>
<p>PostgreSQL may still be useful to you if, for example, you want to have feature toggles in a local database, but the main data kept externally.  However in our case, it also means all developers will need MySQL and PostgreSQL running locally, which is unfortunate.</p>
<p>One workaround is only installing <tt>pg</tt> in production:</p>
<pre># File: Gemfile

# *Only* needed on production.
group :production do
  gem 'pg', '~&gt; 0.11.0' # Regardless of whether you plan to use the database or not, Heroku requires you have 'pg' installed.
end</pre>
<p>Then <tt>bundle</tt> like so:</p>
<pre>$ bundle install --without production</pre>
<p>With our gems updated, commit:</p>
<pre>git commit -av # Commit Gemfile and Gemfile.lock</pre>
<p>Another option may be overriding <tt>database.yml</tt> somehow, although it would add complexity.  For more info, please see <a href="http://stackoverflow.com/questions/4204724/strategies-for-overriding-database-yml">stackoverflow.com/questions/4204724/strategies-for-overriding-database-yml</a>.</p>
<p>With our dependencies out of the way, we can move on to testing the connection.</p>
<p>If you are making a new application, you may wish to have a simple MVC for testing that the connection works.  E.g., for a blog style application with posts do:</p>
<pre>rails generate scaffold post
# NOTE you probably want to change the default "Post.all" to "Post.limit(5)" or something similar
git add .
git commit # ...
# Don't forget to set a default route, etc.</pre>
<p>With all these changes committed, we can deploy to our Heroku app:</p>
<pre>git push heroku master # Your remote may be different</pre>
<p>Now, since we are connecting to an existing database, we don’t need to run any migrations.  (Keep in mind that when sharing a database, it is best to have one authoritative source for migrations to live.)  If in your situation you’re creating a new database, you may need to do that, run migrations, seed the database, etc at this point.</p>
<p>Open <a href="http://our-app.heroku.com">our-app.heroku.com</a> and we should see our data.  If you happen to run into a problem, please check the logs first:</p>
<pre>heroku logs --tail # Again, you may need to specify an app</pre>
<p>If you are having a problem, a good starting point is double checking your passwords, usernames, security settings, etc.</p>
<h4>Example: MySQL with X.509</h4>
<p>The process is very much the same as the above example, except two extra environment variables and files are required.  Below are the extra steps.</p>
<p>What we have:</p>
<ul>
<li>
<p>A CA certificate called <tt>ca-cert.pem</tt></p>
</li>
<li>
<p>A client certificate called <tt>client-cert.pem</tt></p>
</li>
<li>
<p>A client key called <tt>client-key.pem</tt></p>
</li>
</ul>
<p>First, we configure Heroku with the appropriate environment variables:</p>
<pre>heroku config:add EXTERNAL_DATABASE_CA='ca-cert.pem'
heroku config:add EXTERNAL_DATABASE_CERT='client-cert.pem'
heroku config:add EXTERNAL_DATABASE_KEY='client-key.pem'</pre>
<p>By default, <tt>heroku_external_db</tt> looks for the files in <tt>config/ca</tt>, so we need to commit them:</p>
<pre>mkdir -p config/ca
cp path/to/ca-cert.pem path/to/client-cert.pem path/to/client-key.pem config/ca
git add config/ca
git commit</pre>
<p>The rest of the process is the same as in “MySQL with a CA Certificate”.</p>
 <p><a href="http://www.benjaminoakes.com/?flattrss_redirect&amp;id=136&amp;md5=70a5496a6e483e3733a1e38220594cef" title="Flattr" target="_blank"><img src="http://www.benjaminoakes.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/vf9MzuiIRfM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2011/11/21/using-heroku-with-an-external-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=benjaminoakes&amp;url=http%3A%2F%2Fwww.benjaminoakes.com%2F2011%2F11%2F21%2Fusing-heroku-with-an-external-mysql-database%2F&amp;language=en_GB&amp;category=text&amp;title=Using+Heroku+with+an+external+MySQL+database&amp;description=We+recently+had+a+need+to+use+Heroku+with+an+external+MySQL+database.+Thankfully%2C+there+was+already+a+gem+that+solved+the+problem.+However%2C+it+didn%26%238217%3Bt+have+that+much+by...&amp;tags=contribution%2Cdatabase%2Cexternal%2Cgem%2Cheroku%2Cmysql%2Coss%2CRails%2CRuby%2Cblog%2Cruby%2Crails%2Cjavascript%2Csoftware+development%2Cgeek" type="text/html" />
	<feedburner:origLink>http://www.benjaminoakes.com/2011/11/21/using-heroku-with-an-external-mysql-database/</feedburner:origLink></item>
		<item>
		<title>RubyConf 2011</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/NUhLgNl40Hw/</link>
		<comments>http://www.benjaminoakes.com/2011/10/03/rubyconf-2011/#comments</comments>
		<pubDate>Mon, 03 Oct 2011 14:13:37 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[neworleans]]></category>
		<category><![CDATA[rubyconf]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=134</guid>
		<description><![CDATA[RubyConf 2011 was a blast. It was great to meet other Rubyists, get a ton of T-shirts (no really, I got 8 or so), and talk Aaron Patterson into giving Jonathan Magen a special message. If you weren&#8217;t able to go, I pushed my notes up to a public GitHub wiki. A couple others from [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="RubyConf 2011 logo" src="http://confreaks.net/system/events/logos/47/rubyconf2011-logo-small-original.jpg?1317327959" style="width: 100%" /></p>
<p>RubyConf 2011 was a blast.  It was great to meet other Rubyists, get a ton of T-shirts (no really, I got 8 or so), and talk Aaron Patterson into giving Jonathan Magen a <a href="http://www.youtube.com/watch?v=q8PPKWpLmkw">special message</a>.</p>
<p>If you weren&#8217;t able to go, I pushed my notes up to a <a href="https://github.com/benjaminoakes/rubyconf2011/wiki">public GitHub wiki</a>.  A couple others from <a href="http://www.hedgeye.com">Hedgeye</a> are adding their notes as well, so with those (plus the <a href="http://confreaks.net/events/rubyconf2011">Confreaks videos</a> when those guys finally have access to a reliable Internet connection), it&#8217;s almost like you were there.</p>
 <p><a href="http://www.benjaminoakes.com/?flattrss_redirect&amp;id=134&amp;md5=91151acaacb97749e7728141078665af" title="Flattr" target="_blank"><img src="http://www.benjaminoakes.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/NUhLgNl40Hw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2011/10/03/rubyconf-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=benjaminoakes&amp;url=http%3A%2F%2Fwww.benjaminoakes.com%2F2011%2F10%2F03%2Frubyconf-2011%2F&amp;language=en_GB&amp;category=text&amp;title=RubyConf+2011&amp;description=RubyConf+2011+was+a+blast.+It+was+great+to+meet+other+Rubyists%2C+get+a+ton+of+T-shirts+%28no+really%2C+I+got+8+or+so%29%2C+and+talk+Aaron+Patterson+into+giving...&amp;tags=conference%2Cneworleans%2Crubyconf%2Cblog%2Cruby%2Crails%2Cjavascript%2Csoftware+development%2Cgeek" type="text/html" />
	<feedburner:origLink>http://www.benjaminoakes.com/2011/10/03/rubyconf-2011/</feedburner:origLink></item>
		<item>
		<title>ActiveRecord::ConnectionNotEstablished in Rails 3.1 on Heroku</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/GvvQprNiX1M/</link>
		<comments>http://www.benjaminoakes.com/2011/09/15/activerecordconnectionnotestablished-in-rails-3-1-on-heroku/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 15:03:50 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Rails 3.1.0]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=132</guid>
		<description><![CDATA[We have a simple application that doesn&#8217;t have an ActiveRecord dependency. It&#8217;s deployed to Heroku, and it&#8217;s been working fine on Rails 3.0.x since April 2011. We knew we weren&#8217;t using ActiveRecord for database connectivity, but we let it be, since it wasn&#8217;t causing any issues. When upgrading to Rails 3.1, we found that every [...]]]></description>
			<content:encoded><![CDATA[<p>We have a simple application that doesn&#8217;t have an <code>ActiveRecord</code> dependency.  It&#8217;s deployed to Heroku, and it&#8217;s been working fine on Rails 3.0.x since April 2011.  We knew we weren&#8217;t using <code>ActiveRecord</code> for database connectivity, but we let it be, since it wasn&#8217;t causing any issues.</p>
<p>When upgrading to Rails 3.1, we found that every single page would give <code>ActiveRecord::ConnectionNotEstablished</code> on our staging environment on Heroku.  The same error didn&#8217;t happen in development.  Although we might have been able to get <code>gem 'pg'</code> set up and working, we really didn&#8217;t need an ActiveRecord dependency at all.</p>
<p>I found <a href="http://stackoverflow.com/questions/2212709/remove-activerecord-in-rails-3-beta">part of a solution on StackOverflow</a>, but it needed a little tweaking for Rails 3.1.0.</p>
<pre><code># File: config/application.rb

# Pick the frameworks you want:
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
</code></pre>
<p>That&#8217;s what Rails 3.1.0 generates when running <code>rails new myproject --skip-active-record</code>.  (Note that <code>require "active_record/railtie"</code> is commented out.)  This solved our <code>ActiveRecord::ConnectionNotEstablished</code> problem, but gave us a few others, namely:</p>
<ul>
<li>Fixtures</li>
<li><code>ActiveRecord::RecordNotFound</code> (used for 404s)</li>
</ul>
<h4>Fixtures</h4>
<p>There&#8217;s some normal stuff to get rid of in terms of <code>spec_helper.rb</code> and/or <code>test_helper.rb</code>.  Here&#8217;s an example:</p>
<pre><code># File spec/spec_helper.rb

# # If you're not using ActiveRecord, or you'd prefer not to run each of your
# # examples within a transaction, remove the following line or assign false
# # instead of true.
# config.use_transactional_fixtures = true
</code></pre>
<p>You may have others.  <a href="https://rubygems.org/gems/tarantula">Tarantula</a> had to be adjusted for us, for example.</p>
<h4><code>ActiveRecord::RecordNotFound</code></h4>
<p><code>ActiveRecord::RecordNotFound</code>, however, was an interesting problem.  Everything worked fine without <code>ActiveRecord</code> except the places where we were using <code>ActiveRecord::RecordNotFound</code> to give a <code>HTTP 404</code> to the user agent.  That seems strange in a lot of ways, because a <code>404</code> shouldn&#8217;t have anything to do with your chosen ORM.  My first intuition was to do <code>require 'active_record/errors'</code> (see also the <a href="http://api.rubyonrails.org/classes/ActiveRecord/RecordNotFound.html">Rails docs</a>), but that caused problems with assumptions in <code>'rspec/rails'</code>.</p>
<p>Right now, the below is what we ended up with:</p>
<pre><code># File: config/application.rb

# Pick the frameworks you want:
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"

# For errors like ActiveRecord::RecordNotFound
require "active_record"
</code></pre>
<p>Our automated tests (Rspec, integration tests, Tarantula, Selenium, etc) all pass with it and we no longer get <code>ActiveRecord::ConnectionNotEstablished</code>, but we still have an ActiveRecord dependency I don&#8217;t like.  (There must be another error we can raise &#8212; I don&#8217;t entirely like the <code>render '/404.html', status: 404</code> solution for several reasons.)</p>
 <p><a href="http://www.benjaminoakes.com/?flattrss_redirect&amp;id=132&amp;md5=5652b07d177e21b0d4a4861d5350e67c" title="Flattr" target="_blank"><img src="http://www.benjaminoakes.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/GvvQprNiX1M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2011/09/15/activerecordconnectionnotestablished-in-rails-3-1-on-heroku/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=benjaminoakes&amp;url=http%3A%2F%2Fwww.benjaminoakes.com%2F2011%2F09%2F15%2Factiverecordconnectionnotestablished-in-rails-3-1-on-heroku%2F&amp;language=en_GB&amp;category=text&amp;title=ActiveRecord%3A%3AConnectionNotEstablished+in+Rails+3.1+on+Heroku&amp;description=We+have+a+simple+application+that+doesn%26%238217%3Bt+have+an+ActiveRecord+dependency.+It%26%238217%3Bs+deployed+to+Heroku%2C+and+it%26%238217%3Bs+been+working+fine+on+Rails+3.0.x+since+April+2011.+We+knew+we+weren%26%238217%3Bt...&amp;tags=Rails%2CRails+3.1.0%2CRuby%2Cblog%2Cruby%2Crails%2Cjavascript%2Csoftware+development%2Cgeek" type="text/html" />
	<feedburner:origLink>http://www.benjaminoakes.com/2011/09/15/activerecordconnectionnotestablished-in-rails-3-1-on-heroku/</feedburner:origLink></item>
		<item>
		<title>relative_time_ago in Padrino should be time_ago_in_words</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/X7fpgzBzBAE/</link>
		<comments>http://www.benjaminoakes.com/2011/09/14/relative_time_ago-in-padrino-should-be-time_ago_in_words/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 13:01:19 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[helpers]]></category>
		<category><![CDATA[Padrino]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=131</guid>
		<description><![CDATA[You might find relative_time_ago referenced in the Padrino Guides or Padrino Helpers RDocs, but that doesn&#8217;t exist. According to the Application Helpers guides, you probably want distance_of_time_in_words or time_ago_in_words. Example: %p = time_ago_in_words(my_date) ago For reasons I don&#8217;t quite understand, this documentation is also incorrect: time_ago_in_words(2.days.ago) => "2 days ago" The actual behavior is: time_ago_in_words(2.days.ago) [...]]]></description>
			<content:encoded><![CDATA[<p>You might find <code>relative_time_ago</code> referenced in the <a href="http://www.padrinorb.com/guides/home">Padrino Guides</a> or <a href="http://www.padrinorb.com/api/padrino-helpers/README_rdoc.html">Padrino Helpers RDocs</a>, but that doesn&#8217;t exist.</p>
<p>According to the <a href="http://www.padrinorb.com/guides/application-helpers">Application Helpers guides</a>, you probably want <code>distance_of_time_in_words</code> or <code>time_ago_in_words</code>.</p>
<p>Example:</p>
<pre><code>%p
  = time_ago_in_words(my_date)
  ago
</code></pre>
<p>For reasons I don&#8217;t quite understand, this documentation is also <b>incorrect</b>:</p>
<pre><code>time_ago_in_words(2.days.ago) => "2 days ago"</code></pre>
<p>The actual behavior is:</p>
<pre><code>time_ago_in_words(2.days.ago) => "2 days"</code></pre>
<p>I&#8217;m planning to move some of this into the <a href="https://github.com/padrino/padrino-framework">padrino-framework</a> project directly.  Incorrect documentation is worse than no documentation; maybe it will be more accurate if kept in the code.  :)</p>
 <p><a href="http://www.benjaminoakes.com/?flattrss_redirect&amp;id=131&amp;md5=94fcda4c25040250a20c929ee4036774" title="Flattr" target="_blank"><img src="http://www.benjaminoakes.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/X7fpgzBzBAE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2011/09/14/relative_time_ago-in-padrino-should-be-time_ago_in_words/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=benjaminoakes&amp;url=http%3A%2F%2Fwww.benjaminoakes.com%2F2011%2F09%2F14%2Frelative_time_ago-in-padrino-should-be-time_ago_in_words%2F&amp;language=en_GB&amp;category=text&amp;title=relative_time_ago+in+Padrino+should+be+time_ago_in_words&amp;description=You+might+find+relative_time_ago+referenced+in+the+Padrino+Guides+or+Padrino+Helpers+RDocs%2C+but+that+doesn%26%238217%3Bt+exist.+According+to+the+Application+Helpers+guides%2C+you+probably+want+distance_of_time_in_words+or+time_ago_in_words.+Example%3A...&amp;tags=date%2Chelpers%2CPadrino%2CRuby%2Ctime%2Cblog%2Cruby%2Crails%2Cjavascript%2Csoftware+development%2Cgeek" type="text/html" />
	<feedburner:origLink>http://www.benjaminoakes.com/2011/09/14/relative_time_ago-in-padrino-should-be-time_ago_in_words/</feedburner:origLink></item>
	</channel>
</rss>

