<?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>Binary Code &#187; /dev/rails</title>
	<atom:link href="http://www.postal-code.com/binarycode/category/devrails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.postal-code.com/binarycode</link>
	<description>A whole bunch of nought thought by Chris Cummer</description>
	<lastBuildDate>Sun, 29 Jan 2012 16:47:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Rails 3.1, deprecation warning, and primary_key_name</title>
		<link>http://www.postal-code.com/binarycode/2012/01/10/rails-3-1-deprecation-warning-and-primary_key_name/</link>
		<comments>http://www.postal-code.com/binarycode/2012/01/10/rails-3-1-deprecation-warning-and-primary_key_name/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 23:28:55 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[/dev/rails]]></category>

		<guid isPermaLink="false">http://www.postal-code.com/binarycode/?p=550</guid>
		<description><![CDATA[We&#8217;ve spent the past couple days upgrading the Travergence site from Rails 3.0 to 3.1 and while it hasn&#8217;t been entirely smooth, it hasn&#8217;t been horrible either. Except for one issue: DEPRECATION WARNING: primary_key_name is deprecated and will be removed from Rails 3.2 (use foreign_key instead). This would cause recursion somewhere in the stack, eventually [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve spent the past couple days upgrading the Travergence site from Rails 3.0 to 3.1 and while it hasn&#8217;t been entirely smooth, it hasn&#8217;t been horrible either. Except for one issue:</p>
<pre>
DEPRECATION WARNING: primary_key_name is deprecated and will be removed from Rails 3.2 (use foreign_key instead).
</pre>
<p>This would cause recursion somewhere in the stack, eventually leading to:</p>
<pre>
SystemStackError (stack level too deep)
</pre>
<p>After much digging, googling, commenting-out of code, and swearing I finally figured out that it was rails3_acts_as_paranoid causing the issue. One more google led to <a href="https://github.com/goncalossilva/rails3_acts_as_paranoid/pull/46">this solution by Chris Hilton</a>, which involves patching rails3_acts_as_paranoid to prevent circular aliasing.</p>
<p>Hopefully Gonçalo Silva will fix it in the official branch on Github. Until then you can either fork and patch it yourself or grab ours:</p>
<pre>
gem 'rails3_acts_as_paranoid', :git => 'git@github.com:travergence/rails3_acts_as_paranoid.git'
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.postal-code.com/binarycode/2012/01/10/rails-3-1-deprecation-warning-and-primary_key_name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActiveMerchant, Bogus Gateways, and Credit Cards</title>
		<link>http://www.postal-code.com/binarycode/2011/12/05/activemerchant-bogus-gateways-and-credit-cards/</link>
		<comments>http://www.postal-code.com/binarycode/2011/12/05/activemerchant-bogus-gateways-and-credit-cards/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 21:10:25 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[/dev/rails]]></category>

		<guid isPermaLink="false">http://www.postal-code.com/binarycode/?p=545</guid>
		<description><![CDATA[When working with ActiveMerchant&#8216;s BogusGateway, it wants very explicit credit card numbers for testing. But it doesn&#8217;t really want numbers, it wants strings. If you&#8217;re seeing this error, as I was: Bogus Gateway: Use CreditCard number 1 for success, 2 for exception and anything else for error make sure that your 1 and 2 are [...]]]></description>
			<content:encoded><![CDATA[<p>When working with <a href="http://activemerchant.org/">ActiveMerchant</a>&#8216;s <a href="http://activemerchant.rubyforge.org/classes/ActiveMerchant/Billing/BogusGateway.html">BogusGateway</a>, it wants very explicit credit card numbers for testing. But it doesn&#8217;t really want <i>numbers</i>, it wants <i>strings</i>.</p>
<p>If you&#8217;re seeing this error, as I was:</p>
<pre>
Bogus Gateway: Use CreditCard number 1 for success, 2 for exception and anything else for error
</pre>
<p>make sure that your 1 and 2 are <b>not</b> integers but rather are <b>strings</b>.</p>
<p>When you create your credit card instance, I highly recommend casting the number explicitly:</p>
<pre>
ActiveMerchant::Billing::CreditCard.new( :number => number.to_s, :verification_value => security_code.to_s
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.postal-code.com/binarycode/2011/12/05/activemerchant-bogus-gateways-and-credit-cards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rcov, NaN, and Fatal Crashes</title>
		<link>http://www.postal-code.com/binarycode/2009/08/27/rcov-nan-and-fatal-crashes/</link>
		<comments>http://www.postal-code.com/binarycode/2009/08/27/rcov-nan-and-fatal-crashes/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 00:16:46 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[/dev/rails]]></category>
		<category><![CDATA[/dev/ruby]]></category>

		<guid isPermaLink="false">http://www.postal-code.com/binarycode/?p=292</guid>
		<description><![CDATA[Seems its possible to crash the current version of rcov hard under certain circumstances (version as of this writing: rcov (0.8.1.2.0)). If you find it crashing with: ruby(17057,0xa0124720) malloc: *** error for object 0x5b1a602: Non-aligned pointer being freed *** set a breakpoint in malloc_error_break to debug /opt/local/lib/ruby/1.8/rss/rss.rb:274: [BUG] Segmentation fault ruby 1.8.7 (2008-08-11 patchlevel 72) [...]]]></description>
			<content:encoded><![CDATA[<p>Seems its possible to crash the current version of rcov hard under certain circumstances (version as of this writing: <code>rcov (0.8.1.2.0)</code>). If you find it crashing with:</p>
<blockquote><p>
ruby(17057,0xa0124720) malloc: *** error for object 0x5b1a602: Non-aligned pointer being freed<br />
*** set a breakpoint in malloc_error_break to debug<br />
/opt/local/lib/ruby/1.8/rss/rss.rb:274: [BUG] Segmentation fault<br />
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9]<br />
&#8230;<br />
rake aborted!<br />
NaN
</p></blockquote>
<p>Check to see if you have any empty helper files that don&#8217;t have any coverage. I had a couple that resembled the following. Removing them removed the &#8220;divide by zero&#8221; issue that causes the crash:</p>
<pre class="ruby" name="code">
module ProductHelper
end
</pre>
<p><strong>Update</strong><br />
Scratch that, it doesn&#8217;t entirely fix the issue. I&#8217;ve also implemented <a href="http://thestewscope.wordpress.com/2009/07/09/ruby-code-quality-and-metric_fu/">Stew Welbourne&#8217;s hack</a> for <code>round_to_tenths(decimal)</code> in MetricFu but that too does not seem to be a complete solution. The seg fault still happens, though intermittently (sometimes it runs through the complete test suite, sometimes it doesn&#8217;t).</p>
<p>The search continues.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.postal-code.com/binarycode/2009/08/27/rcov-nan-and-fatal-crashes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails, date_select and &#8220;index out of string&#8221;</title>
		<link>http://www.postal-code.com/binarycode/2009/08/11/rails-date_select-and-index-out-of-string/</link>
		<comments>http://www.postal-code.com/binarycode/2009/08/11/rails-date_select-and-index-out-of-string/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 22:17:51 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[/dev/rails]]></category>

		<guid isPermaLink="false">http://www.postal-code.com/binarycode/?p=291</guid>
		<description><![CDATA[If you&#8217;re working in Rails and using date_select() or datetime_select() (and presumably select_date() and select_datetime()) and you find yourself up against an error like the following: index 3873 out of string Check that your :default parameter is either nil or an actual Date/Time/DateTime instance and not a String. Passing in a string as :default really [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re working in Rails and using date_select() or datetime_select() (and presumably select_date() and select_datetime()) and you find yourself up against an error like the following:</p>
<blockquote class="code"><p>
index 3873 out of string
</p></blockquote>
<p>Check that your <code>:default</code> parameter is either <code>nil</code> or an actual Date/Time/DateTime instance and not a String. Passing in a string as <code>:default</code> really messes things up.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.postal-code.com/binarycode/2009/08/11/rails-date_select-and-index-out-of-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Stylesheets Don&#8217;t Route?</title>
		<link>http://www.postal-code.com/binarycode/2008/10/06/my-stylesheets-dont-route/</link>
		<comments>http://www.postal-code.com/binarycode/2008/10/06/my-stylesheets-dont-route/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 19:14:08 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[/dev/rails]]></category>

		<guid isPermaLink="false">http://www.postal-code.com/binarycode/?p=254</guid>
		<description><![CDATA[Over the weekend I was mucking about with my soon-to-be-released-for-public-consumption site when all of a sudden I started getting routing errors on my stylesheets. Madness, that, expecting to need to define a controller and action for stylesheets. Imagine! Turns out the problem was not with routing per se but with the permissions on the public/stylesheet/ [...]]]></description>
			<content:encoded><![CDATA[<p>Over the weekend I was mucking about with my soon-to-be-released-for-public-consumption site when all of a sudden I started getting routing errors on my stylesheets. Madness, that, expecting to need to define a controller and action for stylesheets. Imagine!</p>
<p>Turns out the problem was not with routing per se but with the permissions on the public/stylesheet/ directory. In my mucking it seems I&#8217;d set the permissions on that directory to 777 instead of 755. For whatever reason (I&#8217;m sure it&#8217;s in the Rails source somewhere) that small (and rather dangerously stupid) change switched stylesheet serving from Apache-handled to Rails-handled.</p>
<p>So, beware the permissions for they are strict indeed. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.postal-code.com/binarycode/2008/10/06/my-stylesheets-dont-route/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ultrasphinx Bootstrap Error</title>
		<link>http://www.postal-code.com/binarycode/2008/08/07/ultrasphinx-bootstrap-error/</link>
		<comments>http://www.postal-code.com/binarycode/2008/08/07/ultrasphinx-bootstrap-error/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 21:28:30 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[/dev/rails]]></category>
		<category><![CDATA[/dev/ruby]]></category>

		<guid isPermaLink="false">http://www.postal-code.com/binarycode/?p=238</guid>
		<description><![CDATA[You&#8217;re installing Ultraspinx (perhaps per these instructions from Inoshi, which are the best I&#8217;ve found thus far) and you run into this error when time comes to bootstrap your installation: ~/Sites/ticklists/: sudo rake ultrasphinx:bootstrap &#8211;trace (in /Users/chris/Sites/ticklists) ** Invoke ultrasphinx:bootstrap (first_time) ** Invoke ultrasphinx:_environment (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute ultrasphinx:_environment [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;re installing Ultraspinx (perhaps <a href="http://blog.insoshi.com/2008/07/17/searching-a-ruby-on-rails-application-with-sphinx-and-ultrasphinx/">per these instructions</a> from <a href="http://portal.insoshi.com/">Inoshi</a>, which are the best I&#8217;ve found thus far) and you run into this error when time comes to bootstrap your installation:</p>
<blockquote><p>
~/Sites/ticklists/: sudo rake ultrasphinx:bootstrap &#8211;trace<br />
(in /Users/chris/Sites/ticklists)<br />
** Invoke ultrasphinx:bootstrap (first_time)<br />
** Invoke ultrasphinx:_environment (first_time)<br />
** Invoke environment (first_time)<br />
** Execute environment<br />
** Execute ultrasphinx:_environment<br />
** Invoke ultrasphinx:configure (first_time)<br />
** Invoke ultrasphinx:_environment<br />
** Execute ultrasphinx:configure<br />
rake aborted!<br />
You have a nil object when you didn&#8217;t expect it!<br />
You might have expected an instance of ActiveRecord::Base.<br />
The error occurred while evaluating nil.[]
</p></blockquote>
<p>I couldn&#8217;t find this one in the google anywhere. Turns out the cause of this is defining non-existent properties for indexing on your models (perhaps I&#8217;m the only one dumb enough to do that). </p>
<p>You&#8217;ll know if this is the cause because you&#8217;ll see something akin to this in your Rails console:</p>
<blockquote><p>
** ultrasphinx: warning: field f is not present in User<br />
** ultrasphinx: warning: field descritpion is not present in Profile
</p></blockquote>
<p>Remove (or fix the spelling of) those and everything should work hunky-dory.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.postal-code.com/binarycode/2008/08/07/ultrasphinx-bootstrap-error/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Collision Between Ultrasphinx and TextMate Footnotes</title>
		<link>http://www.postal-code.com/binarycode/2008/08/07/collision-between-ultrasphinx-and-textmate-footnotes/</link>
		<comments>http://www.postal-code.com/binarycode/2008/08/07/collision-between-ultrasphinx-and-textmate-footnotes/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 18:17:31 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[/dev/rails]]></category>

		<guid isPermaLink="false">http://www.postal-code.com/binarycode/?p=237</guid>
		<description><![CDATA[If, when running in production, your Rails app throws the following error: uninitialized constant Footnotes::Filter You&#8217;re probably experiencing a collision between Rails&#8217; initializer.rb file and Footnotes&#8217; initializer.rb file. The fix is detailed at the bottom of Searching a Ruby on Rails application with Sphinx and Ultrasphinx with the specific implementation details available via this github [...]]]></description>
			<content:encoded><![CDATA[<p>If, when running in production, your Rails app throws the following error:</p>
<blockquote class="code"><p>
uninitialized constant Footnotes::Filter
</p></blockquote>
<p>You&#8217;re probably experiencing a collision between Rails&#8217; <code>initializer.rb</code> file and Footnotes&#8217; <code>initializer.rb</code> file.</p>
<p>The fix is detailed at the bottom of <a href="http://blog.insoshi.com/2008/07/17/searching-a-ruby-on-rails-application-with-sphinx-and-ultrasphinx/">Searching a Ruby on Rails application with Sphinx and Ultrasphinx</a> with the specific implementation details available via this github commit: <a href="http://github.com/mhartl/rails-footnotes/commit/9bf8344b2d9ece09ff301dfc4e500e00fd46b9bc">9bf8344b2d9ece09ff301dfc4e500e00fd46b9bc</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.postal-code.com/binarycode/2008/08/07/collision-between-ultrasphinx-and-textmate-footnotes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Two-weekend website: Applican</title>
		<link>http://www.postal-code.com/binarycode/2008/07/13/two-weekend-website-applican/</link>
		<comments>http://www.postal-code.com/binarycode/2008/07/13/two-weekend-website-applican/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 04:57:17 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[/dev/rails]]></category>
		<category><![CDATA[/dev/ruby]]></category>

		<guid isPermaLink="false">http://www.postal-code.com/binarycode/?p=225</guid>
		<description><![CDATA[A couple of weeks ago, in the middle of getting DreamBank ready for launch I was feeling like I needed a break. Of course that meant &#8220;what can I develop in Rails over a single weekend?&#8221; See, I had an idea for an application that would fulfill a need we had at DreamBank: how to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://github.com/senorprogrammer/applican/tree/master"><img src="http://www.postal-code.com/binarycode/wp-content/uploads/2008/07/applican_logo.png" alt="Applican" title="applican_logo" width="66" height="72" align="right" class="alignright size-full wp-image-226" hspace="8" /></a> A couple of weeks ago, in the middle of getting <a href="http://www.dreambank.org">DreamBank</a> ready for launch I was feeling like I needed a break. Of course that meant &#8220;what can I develop in Rails over a single weekend?&#8221; See, I had an idea for an application that would fulfill a need we had at DreamBank: how to manage incoming applicants and resumes against available job positions and I was pretty sure it would go.</p>
<p>My one-weekend project became a two weekend project and a bunch more time was shoe-horned in here and there for bug fixes and improvements until it was finally usable. And then we really got serious about the other launch and development got forgotten; it was released and functional and &#8211; dare I say it &#8211; even useful but neglected.</p>
<p>I now present to you &#8220;<a href="http://github.com/senorprogrammer/applican/tree/master">Applican</a>&#8220;, a Rails-based resume/applicant/job tracker designed (as much as it has been) as an internal tool for small &#038; medium-sized companies. For more details <a href="http://github.com/senorprogrammer/applican/wikis">see the proto-documentation here</a>.</p>
<p>I consider the current release to be about v0.4: it works, it&#8217;s useful, it undoubtedly has bugs, they&#8217;re may not be critical, there&#8217;s definitely functionality to be added. It&#8217;s free, it&#8217;s open-sourced, it&#8217;s available on <a href="http://github.com/senorprogrammer/applican/tree/master">Github</a> and it require Rails 2.1.</p>
<p>(Apologies to <a href="http://www.imdb.com/title/tt0285823/">Robert Rodriguez</a> for stealing and bastardizing one of the best lines in cinema history).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.postal-code.com/binarycode/2008/07/13/two-weekend-website-applican/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails: Won&#8217;t Someone Think of the Children?</title>
		<link>http://www.postal-code.com/binarycode/2008/06/24/rails-wont-someone-think-of-the-children/</link>
		<comments>http://www.postal-code.com/binarycode/2008/06/24/rails-wont-someone-think-of-the-children/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 06:46:01 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[/dev/rails]]></category>
		<category><![CDATA[/dev/ruby]]></category>

		<guid isPermaLink="false">http://www.postal-code.com/binarycode/?p=220</guid>
		<description><![CDATA[I have a class, it acts_as_tree. I want to be able to delete nodes from the tree and heal the rift between grandparent and children, joining them as parent-child afterwards. Seems like it should be pretty obvious but nothing I was coming up with was doing the trick. The node was always deleting yet so [...]]]></description>
			<content:encoded><![CDATA[<p>I have a class, it <code>acts_as_tree</code>. I want to be able to delete nodes from the tree and heal the rift between grandparent and children, joining them as parent-child afterwards. </p>
<p>Seems like it should be pretty obvious but nothing I was coming up with was doing the trick. The node was always deleting yet so were its children. Then I googled upon <a href="http://railsforum.com/viewtopic.php?id=18685">this forum</a> and the solution was found. When executing a <code>before_destroy</code> filter on a class that <code>acts_as_tree</code>, put the before filter first:</p>
<pre name="code" class="rails">
class VettingStage < ActiveRecord::Base
  before_destroy :extract_self_from_chain
  acts_as_tree :foreign_key => "parent_id", <img src='http://www.postal-code.com/binarycode/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> rder => "name"
  ...
end
</pre>
<p>That was easy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.postal-code.com/binarycode/2008/06/24/rails-wont-someone-think-of-the-children/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Ultimate .htaccess File</title>
		<link>http://www.postal-code.com/binarycode/2008/06/20/the-ultimate-htaccess-file/</link>
		<comments>http://www.postal-code.com/binarycode/2008/06/20/the-ultimate-htaccess-file/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 20:47:40 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[/dev/rails]]></category>
		<category><![CDATA[/dev/random]]></category>

		<guid isPermaLink="false">http://www.postal-code.com/binarycode/?p=216</guid>
		<description><![CDATA[This is a thing of beauty: My Webapplication Firewall Tutorial. Note that if you&#8217;re going to use it with a Rails app you&#8217;ll probably want to remove DELETE from line 5.]]></description>
			<content:encoded><![CDATA[<p>This is a thing of beauty: <a href="http://www.0x000000.com/index.php?i=567&#038;bin=1000110111">My Webapplication Firewall Tutorial</a>.</p>
<p>Note that if you&#8217;re going to use it with a Rails app you&#8217;ll probably want to remove DELETE from line 5.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.postal-code.com/binarycode/2008/06/20/the-ultimate-htaccess-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

