<?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>Jordan Brock &#187; rubyonrails</title>
	<atom:link href="http://jordanbrock.com/tag/rubyonrails/feed/" rel="self" type="application/rss+xml" />
	<link>http://jordanbrock.com</link>
	<description>Pith</description>
	<lastBuildDate>Thu, 23 Jun 2011 08:12:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>2nd Gen Accelerators, Rails and attachment_fu</title>
		<link>http://jordanbrock.com/2008/10/17/2nd-gen-accelerators-rails-and-attachment-fu/</link>
		<comments>http://jordanbrock.com/2008/10/17/2nd-gen-accelerators-rails-and-attachment-fu/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 18:38:00 +0000</pubDate>
		<dc:creator>Jordan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[accelerator]]></category>
		<category><![CDATA[joyent]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http:///2008/10/17/2nd-gen-accelerators-rails-and-attachment-fu</guid>
		<description><![CDATA[File this one under WTF. I&#8217;ve been working on an updated version of the Soil Quality website for a little while now, and recently needed to deploy the site to a staging server for testing. I ordered up a 1/4Gb Accelerator from Joyent, configured it, and deployed the app, just like I&#8217;ve done with 20+ [...]]]></description>
			<content:encoded><![CDATA[<p>File this one under <span class="caps">WTF</span>.</p>
<p>I&#8217;ve been working on an updated version of the <a href="http://www.soilquality.org.au">Soil Quality</a> website for a little while now, and recently needed to deploy the site to a staging server for testing. I ordered up a <a href="http://www.joyent.com/accelerator/">1/4Gb Accelerator</a> from <a href="http://www.joyent.com">Joyent</a>, configured it, and <a href="http://wiki.joyent.com/accelerators:deploying_rails_apps">deployed</a> the app, just like I&#8217;ve done with 20+ other sites, and <span class="caps">BOOM</span>, straight into a brick wall.</p>
<p>I opened up the log files and saw this error:</p>
<pre>
** Daemonized, any open files are closed.  Look at /tmp/soilquality-mongrel.8200.pid and log/mongrel.8200.log for info.
** Starting Mongrel listening at 127.0.0.1:8200
** Define INLINEDIR or HOME in your environment and try again
</pre>
<p>Wonderfully descriptive I know, but something I&#8217;d never run into before. So, fire the the google and it turns out it&#8217;s a common error, with a common fix: just put</p>
<p><code>ENV['INLINEDIR'] = RAILS_ROOT + "/tmp"</code></p>
<p>into your config/environment.rb file, make sure the directory exists and that it&#8217;s writeable by the mongrel, restart, and away you go.</p>
<p>But of course, that didn&#8217;t fix it, did it.</p>
<p>Much hair pulling ensued. I finally enlisted the help of <a href="http://blog.ninjahideout.com/">Darcy Laycock</a> and together we managed to track the problem down to the <a href="http://github.com/technoweenie/attachment_fu/tree/master">attachment_fu plugin</a>, which was causing the problem as the mongrel process booted. OK, so now we knew where the problem lay, but what was causing it.</p>
<p>It turned out to be the ImageScience image processor, or more specifically the way the attachment_fu plugin and ImageScience work together <strong><span class="caps">ON A 2ND GENERATION JOYENT ACCELERATOR</span></strong> &#8211; eg the ones that use pkgsrc. Didn&#8217;t seem to cause the problem on an ubuntu machine, nor on one of the older BlastWave based Accelerators. I&#8217;m not sure why as of yet, as I was more worried about getting some sleep last night when we managed to fix the problem.</p>
<p>And the fix? Basically, strip ImageScience out of attachment_fu. Remove</p>
<pre>vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/image_science_processor.rb</pre>
<p>and remove &#8220;ImageScience&#8221; from this line</p>
<pre>@@default_processors = %w(ImageScience Rmagick MiniMagick Gd2 CoreImage)</pre>
<p>in this file</p>
<pre>vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/attachment_fu.rb</pre>
<p>Like I said, I have no real idea why this is happening at the moment, but I&#8217;ll try and work it out and update this post if I get anywhere.</p>
<p>Once again, thanks to Darcy for A) being a sounding board, B) helping fix the problem and C) being up and available when I needed him <img src='http://jordanbrock.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://jordanbrock.com/2008/10/17/2nd-gen-accelerators-rails-and-attachment-fu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Freezing Rails with Git</title>
		<link>http://jordanbrock.com/2008/06/12/freezing-rails-with-git/</link>
		<comments>http://jordanbrock.com/2008/06/12/freezing-rails-with-git/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 03:46:00 +0000</pubDate>
		<dc:creator>Jordan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http:///2008/06/12/freezing-rails-with-git</guid>
		<description><![CDATA[Now that the Ruby On Rails team has moved the codebase over to github, some of the standard rake tasks aren&#8217;t working the way that they used to. When it was on SVN, it was possible to type rake rails:freeze:edge TAG=rel_2-0-1 and the appropriate version would be copied into your vendor/rails directory. Now if you [...]]]></description>
			<content:encoded><![CDATA[<p>Now that the Ruby On Rails team has moved the codebase over to <a href="http://github.com">github</a>, some of the standard rake tasks aren&#8217;t working the way that they used to. When it was on <span class="caps">SVN</span>, it was possible to type</p>
<p><code>rake rails:freeze:edge TAG=rel_2-0-1</code></p>
<p>and the appropriate version would be copied into your vendor/rails directory.</p>
<p>Now if you do that, rake downloads a zip of the edge release. Which is fine and all, but sometimes you don&#8217;t want to be on edge &#8230; like in any production site.</p>
<p>So, I found a <a href="http://smartic.us/2008/5/15/freezing-rails-with-git">screencast</a> that goes through the process, but I thought I&#8217;d actually put the text into a post, mainly for my own reference more than anything else.</p>
<pre>
$ rails path_to_app</p>
<p>$ cd path_to_app</p>
<p>$ git init</p>
<p>$ git submodule add git://github.com/rails/rails.git vendor/rails
</pre >
<p>At this point, git will effectively clone the repository, so that you can then choose one of the branches to &#8220;freeze&#8221; to. Type &#8220;git tag&#8221; to get a list of all the available tagged branches. Choose the one you want and type</p>
<p><code>$ git checkout v2.1.0</code></p>
<p>And that&#8217;s it. Slightly more involved than the old way, but still none too shabby.</p>
]]></content:encoded>
			<wfw:commentRss>http://jordanbrock.com/2008/06/12/freezing-rails-with-git/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting Rails, Git and Capistrano to work on a Joyent Accelerator</title>
		<link>http://jordanbrock.com/2008/04/08/getting-rails-git-and-capistrano-to-work-on-a-joyent-accelerator/</link>
		<comments>http://jordanbrock.com/2008/04/08/getting-rails-git-and-capistrano-to-work-on-a-joyent-accelerator/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 18:51:00 +0000</pubDate>
		<dc:creator>Jordan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[accelerator]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[joyent]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http:///2008/04/08/getting-rails-git-and-capistrano-to-work-on-a-joyent-accelerator</guid>
		<description><![CDATA[After several days of repeatedly smashing my head into both a metaphorical and an all too real brick wall, I seem to have managed to get git and capistrano working happily together on my Joyent Accelerator. I&#8217;m also using github for my git hosting, which threw up it&#8217;s own little challenge mid-way through the entire [...]]]></description>
			<content:encoded><![CDATA[<p>After several days of repeatedly smashing my head into both a metaphorical and an all too real brick wall, I seem to have managed to get <a href="http://git.or.cz">git</a> and <a href="http://capify.org">capistrano</a> working happily together on my <a href="http://www.joyent.com/accelerator">Joyent Accelerator</a>. I&#8217;m also using <a href="http://github.org">github</a> for my git hosting, which threw up it&#8217;s own little challenge mid-way through the entire process.</p>
<p>Now, I should probably also say that I already had my site up and running using subversion, capistrano and my accelerator, so this article isn&#8217;t necessarily going to help with getting everything setup the first time. For that, you probably need to read this <a href="http://wiki.joyent.com/accelerators:deploying_rails_apps">wiki entry</a>.</p>
<h3>Things You Will Need</h3>
<ul>
<li>A github.org account</li>
<li>A dedicated Joyent Accelerator (I have no idea how to do all of this on a shared accelerator. Sorry.)</li>
<li>Also, I&#8217;m really only talking about RubyOnRails apps here &#8230; not too sure how applicable a lot of this is to other frameworks (it will probably help at least.)</li>
</ul>
<h3>Getting started</h3>
<p>Assuming that you have your project in a git repository, and have a <a href="http://github.org">github</a> account (and obviously an Accelerator) we can start.</p>
<h4>Compiling git on your accelerator</h4>
<p>Unfortunately, the first step in the process was, for me at least, a total nightmare. I&#8217;m not the biggest unix-head by any stretch, but I can do some basic tasks with a degree of proficiency. Unfortunately, I went into a dark place trying to get git compiled. One thing to note is that I&#8217;m talking about setting up the git client here, not a git server. Because capistrano executes scripts on your remote server, you need to have a copy of the client software setup for capistrano to call.</p>
<p>So what did I do? There are a couple of helpful threads on the Joyent Forums:</p>
<ul>
<li><a href="http://discuss.joyent.com/viewtopic.php?id=22094">Got git?</a></li>
<li><a href="http://discuss.joyent.com/viewtopic.php?pid=175313">Git and Cap 2.0</a></li>
<li><a href="http://discuss.joyent.com/viewtopic.php?pid=177469#p177469">Installing git</a></li>
</ul>
<p>Hopefully those threads will put you onto the path of successfully compiling and installing git onto your Accelerator.</p>
<h4>Setting up <span class="caps">SSH</span> keys with github and your accelerator</h4>
<p>When you setup your account on github, you need to setup an <span class="caps">SSH</span> key for authentication. github has a <a href="http://github.com/guides/providing-your-ssh-key">really good tutorial</a> on how to do this. I have a user defined on my accelerator that my website &#8220;runs&#8221; under, so what I did was to create a key for that user which gets stored into the ~/.ssh directory. I then added the contents of the id_rsa.pub key to my github account, which allows that user to access the repository.</p>
<p>Another tip: don&#8217;t forget your passphrase. It&#8217;s needed in the next step.</p>
<h4>Configuring capistrano</h4>
<p>Assuming that you have your capistrano deploy.rb file setup as outlined <a href="http://wiki.joyent.com/accelerators:deploying_rails_apps">here</a> there are a few changes that you will need to make to get things working with git.</p>
<p><em>I&#8217;m using Capistrano 2.2 at the moment. I don&#8217;t think it will work with earlier versions because of the relatively new git support.</em></p>
<p>Here&#8217;s my deploy.rb file:</p>
<pre>
  require 'erb'
  require 'config/accelerator/accelerator_tasks'

  set :application, "website"
  set :repository, "git@github.com:your_username/website.git" 

  default_run_options[:pty] = true
  set :domain, 'XX.XX.XX.XX' #Your Accelerators public IP address
  set :deploy_to, "/var/www/apps/#{application}"
  set :user, 'website_account_username'
  set :scm, :git
  set :scm_username, "github_username"
  set :scm_passphrase, "your passphrase here" 

  role :app, domain
  role :web, domain
  role :db,  domain, :primary =&gt; true

  set :server_name, "url.for.website"
  set :server_alias, "*.url.for.website" 

  # Example dependancies
  depend :remote, :command, :gem
  depend :remote, :gem, :money, '&gt;=1.7.1'
  depend :remote, :gem, :mongrel, '&gt;=1.0.1'
  depend :remote, :gem, :image_science, '&gt;=1.1.3'
  depend :remote, :gem, :rake, '&gt;=0.7'
  depend :remote, :gem, :BlueCloth, '&gt;=1.0.0'
  depend :remote, :gem, :RubyInline, '&gt;=3.6.3'

  ################################
  # Some tasks for the old server
  ################################

  task :after_deploy do
    # tasks to run after deploy
  end

  ################################
  # End tasks for the old server
  ################################

  deploy.task :restart do
    accelerator.smf_restart
    accelerator.restart_apache
  end

  deploy.task :start do
    accelerator.smf_start
    accelerator.restart_apache
  end

  deploy.task :stop do
    accelerator.smf_stop
    accelerator.restart_apache
  end

  after :deploy, 'deploy:cleanup'
</pre>
<p>It appears that the important line here is &#8217;  default_run_options[:pty] = true &#8217;. This means that capistrano can respond automatically for the request for the <span class="caps">SSH</span> Key passphrase that github replies with when you try to clone the repository.</p>
<p>If everything is working, you can type &#8216;cap deploy&#8217; and it should all deploy nicely. If you get this error:</p>
<p><code><br />
  [err] Permission denied (publickey).<br />
</code></p>
<p>then there&#8217;s a problem with your <span class="caps">SSH</span> key and your settings on github. Make sure the key you copied into your github account is the public key for the <span class="caps">SSH</span> in your .ssh directory.</p>
<p>Hopefully, you&#8217;ll be up and running. If you have any tips, recommendations or corrections, leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://jordanbrock.com/2008/04/08/getting-rails-git-and-capistrano-to-work-on-a-joyent-accelerator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading to Capistrano 2</title>
		<link>http://jordanbrock.com/2007/09/14/upgrading-to-capistrano-2/</link>
		<comments>http://jordanbrock.com/2007/09/14/upgrading-to-capistrano-2/#comments</comments>
		<pubDate>Thu, 13 Sep 2007 23:17:00 +0000</pubDate>
		<dc:creator>Jordan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[deploy]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http:///2007/09/14/upgrading-to-capistrano-2</guid>
		<description><![CDATA[For no other reason than this is something I need to remember on other projects, here is a list of the changes I made when I uninstalled deprec and upgraded to capistrano 2 for deployment. Things to do Do this once gem install mongrel_cluster then in the application directory capify . then remove &#8220;require &#8216;deprec/recipes&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p>For no other reason than this is something I need to remember on other projects, here is a list of the changes I made when I uninstalled deprec and upgraded to <a href="http://capify.org">capistrano 2</a> for deployment.</p>
<h3>Things to do</h3>
<p>Do this once</p>
<p><code><br />
gem install mongrel_cluster<br />
</code></p>
<p>then in the application directory</p>
<p><code><br />
capify .<br />
</code></p>
<p>then remove &#8220;require &#8216;deprec/recipes&#8217; from the deploy.rb file</p>
<p>then put the following in to the deploy.rb file</p>
<p><code><br />
namespace :deploy do<br />
  task :start,    :roles =&gt; :app do start_mongrel_cluster end<br />
  task :stop,     :roles =&gt; :app do stop_mongrel_cluster end<br />
  task :restart,  :roles =&gt; :app do restart_mongrel_cluster end<br />
end<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://jordanbrock.com/2007/09/14/upgrading-to-capistrano-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maps, Geocoding and Great Timing</title>
		<link>http://jordanbrock.com/2007/02/10/maps-geocoding-and-great-timing/</link>
		<comments>http://jordanbrock.com/2007/02/10/maps-geocoding-and-great-timing/#comments</comments>
		<pubDate>Fri, 09 Feb 2007 19:17:00 +0000</pubDate>
		<dc:creator>Jordan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[geocoding]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http:///2007/02/10/maps-geocoding-and-great-timing</guid>
		<description><![CDATA[On one of the sites I&#8217;ve been working on for quite a while (SchoolSeek) we&#8217;ve been wanting to add the ability for users to find out how far a school is from their current location. There are services that have been able to geocode addresses for a while, but they were either based in the [...]]]></description>
			<content:encoded><![CDATA[<p>On one of the sites I&#8217;ve been working on for quite a while (<a href="http://www.schoolseek.com.au">SchoolSeek</a>) we&#8217;ve been wanting to add the ability for users to find out how far a school is from their current location. There are services that have been able to <a href="http://en.wikipedia.org/wiki/Geocode">geocode</a> addresses for a while, but they were either based in the US, or cost money. Not a lot of money, but free is always good.</p>
<p>A couple of years ago, <a href="http://maps.google.com">Google Maps</a> launched in the US and opened up a massive range of possibilities for programmers to develop cool &#8220;mashups&#8221;, which took information from one site, mashed it together with maps from google, and created a whole new website. They were all really cool, but unfortunately (at least for the non-US based of us) it was nothing more than something we could sit back and watch &#8211; which was kind of weird because the team of developers that built Google Maps was based in Sydney.</p>
<p>But <a href="http://googleblog.blogspot.com/2006/05/on-map-down-under.html">finally</a> the Australian version of google maps was released, and then recently integrated with Local Search, which means you can search on Pizza shotps near a particular address. Which is cool.</p>
<p>What is even cooler (if you&#8217;re a ruby developer), though, is the release of this: <a href="http://geokit.rubyforge.org/">GeoKit</a>. It integrates with all of the major geocoding/mapping services and provides a huge range of options and services. So now you can do stuff like this:</p>
<pre>
add_1=GeoKit::Geocoders::GoogleGeocoder.geocode("1 St Georges Terrace, Perth, Western Australia")
add_2=GeoKit::Geocoders::GoogleGeocoder.geocode("1 York St, Albany, Western Australia")

distance = add_1.distance_from(add_2, :units =&gt; :kms)
</pre>
<p>Which returns</p>
<p><code><br />
389.248018478531<br />
</code></p>
<p>which is, of course, how far it is between the main streets of Perth and Albany in Western Australia.</p>
<p>Sawwweeeeeet.</p>
<h3>Update</h3>
<p>Well, that didn&#8217;t take long at all. A quick loop over the existing schools in the <a href="http://www.schoolseek.com.au">SchoolSeek</a> database got the lat/long information for all the addresses. Then adding this line</p>
<pre>acts_as_mappable default_units =&gt; :kms</pre>
<p>to my Address model allows you to do this</p>
<pre>
@addresses = Address.find(:all, <img src='http://jordanbrock.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> rigin =&gt; "18 Bland St, Ashfield, New South Wales", :conditions =&gt; "distance &lt; 10")
</pre>
<p>which gives me all of the addresses within 10Kms of 18 Bland St, Ashfield. Nice.</p>
<p>So, basically GeoKit let me add distance searching to the site within about 45 minutes (allowing 25 minutes for me to read through the examples and such!)</p>
]]></content:encoded>
			<wfw:commentRss>http://jordanbrock.com/2007/02/10/maps-geocoding-and-great-timing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Handy RubyOnRails Tips</title>
		<link>http://jordanbrock.com/2006/07/09/handy-rubyonrails-tips/</link>
		<comments>http://jordanbrock.com/2006/07/09/handy-rubyonrails-tips/#comments</comments>
		<pubDate>Sun, 09 Jul 2006 18:22:00 +0000</pubDate>
		<dc:creator>Jordan</dc:creator>
				<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http:///2006/07/09/handy-rubyonrails-tips</guid>
		<description><![CDATA[19 Rails Tricks Most Rails Coders Don&#8217;t Know When looking at my own Rails code and that of the community as a whole, I often see places where certain Rails techniques could have been used, but weren&#8217;t. As much for my own memory as yours, I thought I&#8217;d list down some Rails tricks and tips [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.rubyinside.com/19-rails-tricks-most-rails-coders-dont-know-131.html">19 Rails Tricks Most Rails Coders Don&#8217;t Know</a></p>
<blockquote><p>When looking at my own Rails code and that of the community as a whole, I often see places where certain Rails techniques could have been used, but weren&#8217;t. As much for my own memory as yours, I thought I&#8217;d list down some Rails tricks and tips that can make your application or code more efficient:</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://jordanbrock.com/2006/07/09/handy-rubyonrails-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

