<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:gd="http://schemas.google.com/g/2005" gd:etag="W/&quot;C0QFRXwzfCp7ImA9WhdVFko.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111</id><updated>2011-09-21T23:01:54.284-07:00</updated><title>Nathan Humbert's Blog</title><subtitle type="html">Pseudorandom thoughts, mostly on programming and web application development.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>23</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/NathanHumbert" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="nathanhumbert" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;CkUBQnk7fSp7ImA9WhdWFU8.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-1708624535645326192</id><published>2011-09-08T15:08:00.000-07:00</published><updated>2011-09-08T15:17:33.705-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-08T15:17:33.705-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="ruby 1.9" /><category scheme="http://www.blogger.com/atom/ns#" term="code coverage" /><title>Rails Code QA Update</title><content type="html">&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;I just released an updated version of Rails Code QA which now supports rails 3.0 and 3.1 as well as ruby 1.8.x and ruby 1.9.x&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;Installation&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;If you are using ruby 1.8.x all you need to do to install rails_code_qa in your rails 3.x app is add the following line to your Gemfile.
&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;gem "rails_code_qa"&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;br /&gt;
If you are using ruby 1.9.x you will also need to add the following to your test/test_helper.rb file
&lt;br /&gt;
&lt;pre&gt;require 'simplecov'
SimpleCov.start 'rails'&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Code Coverage&lt;/b&gt;&lt;br /&gt;
Rails Code QA takes care of picking which code coverage tool to use based on the version of ruby you are using. If you are using ruby 1.8.x code coverage is calculated using&amp;nbsp;&lt;a href="https://github.com/relevance/rcov"&gt;rcov&lt;/a&gt;&amp;nbsp;and if you are using ruby 1.9.x coverage is calculated using&amp;nbsp;&lt;a href="https://github.com/colszowka/simplecov"&gt;simplecov&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Static Code Analysis&lt;/b&gt;&lt;br /&gt;
Rails Code QA also runs&amp;nbsp;&lt;a href="https://github.com/seattlerb/flog"&gt;flog&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://github.com/seattlerb/flay"&gt;flay&lt;/a&gt;&amp;nbsp;to help you find other issues in your apps code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Resources&lt;/b&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/nathanhumbert/rails_code_qa"&gt;Rails Code QA on Github&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.nathanhumbert.com/2010/03/rails-3-code-coverage-with-rcov.html"&gt;Initial release blog post&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-1708624535645326192?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/1708624535645326192/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=1708624535645326192" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/1708624535645326192?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/1708624535645326192?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2011/09/rails-code-qa-update.html" title="Rails Code QA Update" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total><georss:featurename>Walla Walla, WA 99362, USA</georss:featurename><georss:point>46.0645809 -118.3430209</georss:point><georss:box>46.0205119 -118.4219849 46.1086499 -118.2640569</georss:box></entry><entry gd:etag="W/&quot;D0QBRn47eCp7ImA9WhZSE0g.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-219827708699150636</id><published>2011-03-28T16:33:00.000-07:00</published><updated>2011-03-28T16:35:57.000-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-28T16:35:57.000-07:00</app:edited><title>Sitemap testing with doublecheck</title><content type="html">I hate releasing a new version of a site and finding out a few days later that I broke some of the pages. So I wrote the Doublecheck gem to help with post release testing.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Doublecheck&lt;/h3&gt;Doublecheck pulls a sitemap file and checks each URL listed, outputing a list of URL's for each HTTP status code that is encountered.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Installation&lt;/h3&gt;&lt;pre&gt;$ gem install doublecheck
&lt;/pre&gt;&lt;br /&gt;
&lt;h3&gt;Usage&lt;/h3&gt;&lt;pre&gt;$ doublecheck http://example.com/sitemap.xml
&lt;/pre&gt;&lt;br /&gt;
&lt;h3&gt;Notes&lt;/h3&gt;Get the code: &lt;a href="https://github.com/nathanhumbert/doublecheck"&gt;github.com/nathanhumbert/doublecheck&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Doublecheck is pretty simple at this point, it does one request at a time, so large sites may take a substantial amount of time to process.&lt;br /&gt;
&lt;br /&gt;
Google's &lt;a href="http://www.google.com/webmasters/tools/ "&gt;webmaster tools&lt;/a&gt; will eventually let you know if one of your pages has a problem, but it isn't a particularly fast way to find issues on your site.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-219827708699150636?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/219827708699150636/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=219827708699150636" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/219827708699150636?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/219827708699150636?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2011/03/sitemap-testing-with-doublecheck.html" title="Sitemap testing with doublecheck" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;D0MEQXwyeip7ImA9Wx9UGE4.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-473364163537659557</id><published>2011-02-15T21:50:00.000-08:00</published><updated>2011-02-15T21:50:00.292-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-15T21:50:00.292-08:00</app:edited><title>Using Sinatra with Bundler to deploy on Heroku</title><content type="html">I decided to try using sinatra for a &lt;a href="http://games.humbert.co/tictactoe"&gt;small project&lt;/a&gt; I started the other day. I normally work in &lt;a href="http://rubyonrails.org"&gt;rails&lt;/a&gt; and host my personal projects on &lt;a href="http://heroku.com"&gt;heroku&lt;/a&gt;. Since rails 3 came out I have also gotten hooked on bundler. I could not find any single source that documented how to use all of these together nicely. Here is how I got it to work.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Gemfile&lt;/h3&gt;The gemfile is pretty basic, set a source for gems and include the sinatra gem.&lt;br /&gt;
&lt;pre&gt;source :rubygems
gem 'sinatra'
&lt;/pre&gt;&lt;br /&gt;
&lt;h3&gt;config.ru&lt;/h3&gt;This is the rackup config file which sets the app up to run in rack.&lt;br /&gt;
&lt;pre&gt;require 'rubygems'
require 'bundler'

Bundler.require

require './myapp'

run MyApp
&lt;/pre&gt;&lt;br /&gt;
&lt;h3&gt;myapp.rb&lt;/h3&gt;This is the sinatra file. Note that I defined a class (MyApp). This is very important because our config.ru needs the class as a handle for the 'run MyApp' call. An alternative would be to use "run Sinatra::Application" in your config.ru file.&lt;br /&gt;
&lt;pre&gt;class MyApp &lt; Sinatra::Base
  get '/' do
    'Hello world!'
  end
end
&lt;/pre&gt;
&lt;h3&gt;Running locally&lt;/h3&gt;First make sure rack is installed, then run the following commands in the root folder and the app should be up and running locally.
&lt;pre&gt;bundle install
rackup
&lt;/pre&gt;&lt;h3&gt;Deploying to Heroku&lt;/h3&gt;Just run the following commands in the root folder and the app should be up and running on Heroku.
&lt;pre&gt;git init
git add .
git commit -m 'Initial version of MyApp'
heroku create
git push heroku master
&lt;/pre&gt;&lt;h3&gt;Additional resources&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://devcenter.heroku.com/articles/rack#frameworks"&gt;Heroku Rack documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.sinatrarb.com/intro#Scopes%20and%20Binding"&gt;Sinatra Application/Class Scope documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://gembundler.com/sinatra.html"&gt;Bundler Sinatra documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-473364163537659557?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/473364163537659557/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=473364163537659557" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/473364163537659557?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/473364163537659557?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2011/02/using-sinatra-with-bundler-to-deploy-on.html" title="Using Sinatra with Bundler to deploy on Heroku" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>5</thr:total></entry><entry gd:etag="W/&quot;DUUEQnw6fip7ImA9Wx9WGEU.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-4843242154552877723</id><published>2011-01-23T19:00:00.000-08:00</published><updated>2011-01-24T08:40:03.216-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-24T08:40:03.216-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="caching" /><category scheme="http://www.blogger.com/atom/ns#" term="rails3" /><title>Easy data caching in Rails 3</title><content type="html">&lt;h3&gt;Three common forms of caching&lt;/h3&gt;There are 3 types of caching that are very commonly talked about in the rails community; &lt;a href="http://guides.rubyonrails.org/caching_with_rails.html#page-caching"&gt;page caching&lt;/a&gt;, &lt;a href="http://guides.rubyonrails.org/caching_with_rails.html#action-caching"&gt;action caching&lt;/a&gt;, and &lt;a href="http://guides.rubyonrails.org/caching_with_rails.html#fragment-caching"&gt;fragment caching&lt;/a&gt;. All of these are well documented and are great ways to cache varying amounts of content for your pages.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Is that all the caching I need?&lt;/h3&gt;Caching at the view level is great but it isn't necessarily the best fit for every situation. In some cases it may be easier to cache data at a lower level. Perhaps you want to cache the results of an external data request for a given period of time. None of the view caching methods would be a really great fit.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Lower level data caching&lt;/h3&gt;Rails 3 actually has a great method for caching data at a lower level than the view. It even uses the same caching store as action and fragment caching. &lt;a href="http://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html"&gt;ActiveSupport::Cache::Store&lt;/a&gt; allows you to store any serializable Ruby object. Rails even provides an already initialized cache store via Rails.cache.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Example usage and code&lt;/h3&gt;I used this on &lt;a href="http://www.checkthesock.com"&gt;www.checkthesock.com&lt;/a&gt; to cache METAR queries. I was using &lt;a href="https://github.com/nathanhumbert/current_metar"&gt;current_metar&lt;/a&gt; a gem I built that pulls metar data from &lt;a href="http://weather.aero/" title="Aviation Digital Data Service"&gt;ADDS&lt;/a&gt;. I made a model called CachedMetar to return cached results to the rest of my application.&lt;br /&gt;
&lt;script src="https://gist.github.com/792436.js?file=cached_metar.rb"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Code walk through &lt;/h3&gt;This model basically returns the result of the block argument to &lt;code&gt;Rails.cache.fetch&lt;/code&gt; the first time it is called. Any time it is called within the next 5 minutes it returns the value that was cached the first time. Everywhere I had previously been calling &lt;code&gt;CurrentMetar::Metar.get_metar("ICAO code")&lt;/code&gt; I switched to call &lt;code&gt;CachedMetar.metar("ICAO code")&lt;/code&gt; and that was all it took.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Testing&lt;/h3&gt;Testing is actually surprisingly easy. I used shoulda and mocha and here is what I ended up with.&lt;br /&gt;
&lt;script src="https://gist.github.com/792716.js?file=cached_metar_test.rb"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Reference&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://guides.rubyonrails.org/caching_with_rails.html"&gt;RailsGuides Caching guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html"&gt;Rails API docs: ActiveSupport::Cache::Store&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://api.rubyonrails.org/classes/Rails.html"&gt;Rails API docs: Rails&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-4843242154552877723?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/4843242154552877723/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=4843242154552877723" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/4843242154552877723?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/4843242154552877723?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2011/01/data-caching-in-rails-3.html" title="Easy data caching in Rails 3" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;Ck8EQXgzeSp7ImA9Wx9WFkg.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-2170057381888176712</id><published>2011-01-21T15:00:00.000-08:00</published><updated>2011-01-21T15:00:00.681-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-21T15:00:00.681-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jquery" /><category scheme="http://www.blogger.com/atom/ns#" term="SEO" /><category scheme="http://www.blogger.com/atom/ns#" term="google maps" /><title>SEO friendly maps with jQuery</title><content type="html">In my free time I am working on a &lt;a href="http://www.checkthesock.com"&gt;social networking site for RC pilots&lt;/a&gt;. I have information pages for various RC airfields and I was looking for a good way to display a listing of the fields. Putting markers on an embedded google map is a great way to display this type of data to users. The method I have seen recommended for this is to make separate list and map views. I don't really think that is a great user experience though.&lt;br /&gt;
&lt;br /&gt;
The main reason making two pages is suggested is that maps require many lines of code and JavaScript functions that will dilute your content. The solution I arrived at was to use as little javascript as possible to generate my map. I ended up accomplishing this by using javascript to parse the content of the page to generate the markers. &lt;br /&gt;
&lt;br /&gt;
To be able to easily parse out the data I wanted to display on the map I ended up making my own microformat. I put a class of field on the div that contained each field I was showing on the page. In that div I put the content that I wanted to display in the information popup for each marker. Then in that div I put two spans that contained the latitude and longitude and gave them each a class. The results ended up looking like this:&lt;br /&gt;
&lt;script src="https://gist.github.com/790484.js?file=field_snippet.html"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
Then I wrote some javascript to parse this microformat and generate markers for my map. I used jQuery selectors to select each field in the html. For each field the latitude, longitude, and html contents are selected. Then the add_marker method is called to setup the marker with that data. After the marker is created I hide the field div. &lt;br /&gt;
&lt;script src="https://gist.github.com/790495.js?file=parse_for_map.js"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
Users with javascript will see a map with a bunch of markers that have an information bubble when clicked on. Users that do not have javascript enabled will see a list of field information. The textual content is the same for both users, the users with javascript just get an improved experience.&lt;br /&gt;
&lt;br /&gt;
Go to &lt;a href="http://www.checkthesock.com/fields"&gt;www.checkthesock.com/fields&lt;/a&gt; to see the end result.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-2170057381888176712?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/2170057381888176712/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=2170057381888176712" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/2170057381888176712?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/2170057381888176712?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2011/01/seo-friendly-maps-with-jquery.html" title="SEO friendly maps with jQuery" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>5</thr:total></entry><entry gd:etag="W/&quot;C0UEQnwzeSp7ImA9Wx5XGUQ.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-876521250152582838</id><published>2010-09-20T07:00:00.000-07:00</published><updated>2010-09-20T07:00:03.281-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-09-20T07:00:03.281-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="testing" /><title>Getting over assert_difference</title><content type="html">For quite a while now I have been using assert_difference or its close cousin from shoulda should_change. When I recently updated to a recent version of shoulda I noticed that they had deprecated should_change. The note in the shoulda documentation says the following: &lt;i&gt;"This macro was deprecated because these tests aren’t as valuable as alternative tests that explicitly test the final state."&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Ok, now what to do? assert_change is super easy to use, but does it really ensure that the desired action is actually happening? For example:&lt;br /&gt;
&lt;script src="http://gist.github.com/587478.js?file=gistfile1.rb"&gt;&lt;/script&gt;&lt;br /&gt;
This example test asserts that the number of User objects in the database has increased by 1. No real guarantee that it was actually the User object we were interested in creating. &lt;br /&gt;
&lt;br /&gt;
Lately I have been trying to be a little more explicit about what is actually happening. It is taking a little while to get used to doing things this way but the results have been satisfying. Here is an example:&lt;br /&gt;
&lt;script src="http://gist.github.com/587485.js?file=gistfile1.rb"&gt;&lt;/script&gt;&lt;br /&gt;
This example test asserts that a User object is getting assigned to the @user instance variable and that User object is no longer a new record.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-876521250152582838?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/876521250152582838/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=876521250152582838" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/876521250152582838?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/876521250152582838?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2010/09/getting-over-assertdifference.html" title="Getting over assert_difference" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;DkMER3k5eip7ImA9Wx5QGUg.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-2051858851132471720</id><published>2010-09-08T07:00:00.000-07:00</published><updated>2010-09-08T07:00:06.722-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-09-08T07:00:06.722-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="readability" /><category scheme="http://www.blogger.com/atom/ns#" term="numeric literals" /><title>Code Readability: Quick, Millions or Billions?</title><content type="html">&lt;h3&gt;3193490646&lt;/h3&gt;&lt;p&gt;It is really easy to get the order of magnitude wrong on a number in code. I had settled into the habit of carefully counting my digits to make sure it was right until one of my co-workers pointed out a neat feature of ruby.&lt;p&gt;&lt;p&gt;Ruby allows underscores to be inserted into numbers between any two digits. The underscores are purely cosmetic and do not affect the value of the number. This feature allows a developer to use underscores as an accountant might use commas.&lt;/p&gt;&lt;pre&gt;3193490646      # standard representation of a number in ruby
3_193_490_646   # same value, much more readable
&lt;/pre&gt;&lt;p&gt;One less excuse for order of magnitude errors when using ruby.&lt;/p&gt;&lt;p&gt;A little looking around did not find any similar functionality in other languages, I checked into C/C++, Smalltalk, Python, Perl, PHP, Java, Javascript, Lisp, and Erlang. I am very curious to know if anyone knows of another language or particular implementation of one of the listed languages that supports similar functionality.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Thanks to &lt;a href="http://dallasreedy.com"&gt;Dallas Reedy&lt;/a&gt; for introducing me to this awesome feature of Ruby&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-2051858851132471720?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/2051858851132471720/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=2051858851132471720" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/2051858851132471720?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/2051858851132471720?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2010/09/code-readability-quick-millions-or.html" title="Code Readability: Quick, Millions or Billions?" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>5</thr:total></entry><entry gd:etag="W/&quot;CkUASHw5fyp7ImA9WxFTFU0.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-6646844871687403977</id><published>2010-04-04T22:15:00.000-07:00</published><updated>2010-04-05T13:44:09.227-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-05T13:44:09.227-07:00</app:edited><title>Rails Code Stats gem</title><content type="html">&lt;p&gt;When rails 2.2 came out it added some syntactic sugar by implementing a declarative block syntax for tests. The syntax for this looks like this:&lt;/p&gt;&lt;pre&gt;test "make sure something really critical happens" do
  #code that tests for something really critical
end
&lt;/pre&gt;&lt;p&gt;While this syntax update is great some of the tools that come with rails still haven't been updated to handle it nicely. The stats rake task which outputs basic code statistics such as lines of code and methods per class still doesn't count these tests. In the past I just copied the rake tasks code and made a new rake task that could handle the new syntax as well as the format shoulda uses. After I started playing around with rails 3 and figured out &lt;a href="http://blog.nathanhumbert.com/2010/02/rails-3-loading-rake-tasks-from-gem.html"&gt;how to put rake tasks in a gem&lt;/a&gt; I decided to write a gem that would generate an improved stats output.&lt;/p&gt;&lt;h3&gt;Introducing &lt;a href="http://rubygems.org/gems/rails_code_stats"&gt;Rails Code Stats&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;For this gem I didn't just copy the code and slightly improve the output. I refactored the code to clean things up as well as making it easier to extend functionality. One of the main changes was separating the code that calculates the stats from the code that displays the stats. Currently it still just outputs to the command line, but I intend to add the ability to have it output a HTML version as well. In addition to the new test syntax introduced in rails 2.2, I also added support for shoulda's test syntax and improved the code so that it should be quite trivial to add support for another test method syntax. Installing this plugin is as easy as adding the following to your rails 3 applications Gemfile.&lt;/p&gt;&lt;pre&gt;gem 'rails_code_stats'
&lt;/pre&gt;&lt;p&gt;I am contemplating suggesting to the rails core team as an alternative to the current rails stats task. It seems that it fits with where rails 3 is trying to go, if you can easily swap out DB persistance layers and javascript engines why not modularize the code statistics tool as well. Please comment if you have any suggestions on improving this gem.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-6646844871687403977?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/6646844871687403977/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=6646844871687403977" title="7 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/6646844871687403977?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/6646844871687403977?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2010/04/rails-3-rails-code-stats.html" title="Rails Code Stats gem" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>7</thr:total></entry><entry gd:etag="W/&quot;A04HQHY_cCp7ImA9WhdWFUw.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-6275241219077606126</id><published>2010-03-15T22:09:00.000-07:00</published><updated>2011-09-08T15:12:11.848-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-08T15:12:11.848-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rails 3" /><category scheme="http://www.blogger.com/atom/ns#" term="code coverage" /><title>Rails 3: Code coverage with rcov</title><content type="html">&lt;b&gt;UPDATE: &lt;/b&gt;&lt;a href="http://blog.nathanhumbert.com/2011/09/rails-code-qa-update.html"&gt;Added support for ruby 1.9 and rails 3.1&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I use &lt;a href="http://github.com/relevance/rcov"&gt;rcov&lt;/a&gt; to make sure I have 100% test coverage on my rails projects. In earlier versions of rails I used the rails_rcov plugin to accomplish this task. Since &lt;a href="http://blog.nathanhumbert.com/2010/02/rails-3-loading-rake-tasks-from-gem.html"&gt;rails 3 allows rake tasks to be imported by gems&lt;/a&gt;, I decided to write a gem with a rake task that reports on code coverage.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;rails_code_qa&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
Currently &lt;a href="http://github.com/nathanhumbert/rails_code_qa"&gt;rails_code_qa&lt;/a&gt; runs the unit, functional, and integration tests for a Rails 3 app. It generates 2 different coverage reports. Unit test coverage is calculated on models, helpers, and lib; functional test coverage is calculated on the controllers. Coverage is not calculated on integration tests. In my experience I have found this to be a good way to calculate coverage because it encourages you to write unit tests that cover your core code very well.&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Install&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
All you need to do to install rails_code_qa in your rails 3 app is add the following line to your Gemfile.&lt;/div&gt;
&lt;pre&gt;gem "rails_code_qa"&lt;/pre&gt;
Then update the bundle for the rails app with the following command.&lt;br /&gt;
&lt;pre&gt;bundle install&lt;/pre&gt;
Bundler automatically pulls from &lt;a href="http://rubygems.org/"&gt;rubygems.org&lt;/a&gt; and installs any dependencies (rcov) that rails_code_qa needs.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Usage&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
rails_code_qa adds a few useful rake tasks to your rails app.&lt;/div&gt;
&lt;pre&gt;rake rcqa              #all tests with coverage reports  
rake rcqa:units        #unit tests with coverage
rake rcqa:functionals  #functional tests with coverage
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Future&lt;/b&gt;&lt;br /&gt;
I plan to add other code quality tools to this gem in the future. Likely candidates include flog, flay, and roodi. Feel free to leave a comment if you know of another code quality tool that you think I should include.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-6275241219077606126?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/6275241219077606126/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=6275241219077606126" title="13 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/6275241219077606126?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/6275241219077606126?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2010/03/rails-3-code-coverage-with-rcov.html" title="Rails 3: Code coverage with rcov" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>13</thr:total></entry><entry gd:etag="W/&quot;CEQBQnw-eip7ImA9WxFTFU8.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-7884096005912857197</id><published>2010-03-07T21:11:00.000-08:00</published><updated>2010-04-05T19:52:33.252-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-05T19:52:33.252-07:00</app:edited><title>Rails 3: Heroku</title><content type="html">Last week I was pleased to discover that Heroku now supports the rails 3 beta. To use it you have to switch the application stack. The main Heroku stack (&lt;a href="http://docs.heroku.com/aspen"&gt;Argent Aspen&lt;/a&gt;) runs ruby 1.8.6 which does not work with Rails 3. Heroku &lt;span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;"&gt;enabled a new stack (&lt;a href="http://docs.heroku.com/bamboo"&gt;Badious Bamboo&lt;/a&gt;) which runs either &lt;a href="http://www.rubyenterpriseedition.com/"&gt;Ruby Enterprise Edition&lt;/a&gt; 1.8.7 &amp;nbsp;or MRI 1.9.1 which both support Rails 3.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;"&gt;To get your Rails 3 app running on Heroku you need switch to your stack by following the &lt;a href="http://docs.heroku.com/stack"&gt;Heroku stacks documentation&lt;/a&gt;. After you have the correct stack set up you need to make sure you have &lt;b&gt;all &lt;/b&gt;of your gems set up in your Gemfile. I ran into issues because I use SQLite during development and I didn't have the required pg gem set up in my Gemfile.&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;"&gt;That is all there is to getting up and running. I tried out a few of the add-ons, none of them seemed to break my app, but they did not all work quite right. The New Relic add-on reported on deployments but it still has not registered a single request.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt; Rails 3 beta2 breaks on heroku when the New Relic add-on is added.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-7884096005912857197?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/7884096005912857197/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=7884096005912857197" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/7884096005912857197?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/7884096005912857197?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2010/03/rails-3-heroku.html" title="Rails 3: Heroku" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>5</thr:total></entry><entry gd:etag="W/&quot;D0YFSH07fCp7ImA9WxFREE4.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-9159619578669516147</id><published>2010-02-16T22:11:00.000-08:00</published><updated>2010-04-23T08:05:19.304-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-23T08:05:19.304-07:00</app:edited><title>Rails 3: Loading rake tasks from a gem</title><content type="html">Several times in the last year I have wished that a gem could have rake tasks that would be loaded into a Rails app. I looked into it several times but kept running into dead ends with Rails 2. Since the Rails 3 beta came out I decided to try again, this time with much more success.&lt;br /&gt;
&lt;br /&gt;
Basically you are trying to include a rake task in your rails app, the tricky part is you are trying to include the rake task from the gem it is inside of, which itself is being included in the rails app.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Gem file structure&lt;/b&gt;&lt;br /&gt;
&lt;pre&gt;my_plugin.gemspec
lib/my_plugin.rb
lib/my_plugin/railtie.rb
tasks/my_plugin.rake
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;lib/my_plugin.rb&lt;/b&gt;&lt;br /&gt;
&lt;pre&gt;module MyPlugin
  require 'my_plugin/railtie' if defined?(Rails)
end
&lt;/pre&gt;This file is automatically included as part of including the gem using bundler. All we need to do in this file is require our railtie.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;lib/my_plugin/railtie.rb&lt;/b&gt;&lt;br /&gt;
&lt;pre&gt;require 'my_plugin'
require 'rails'
module MyPlugin
  class Railtie &amp;lt; Rails::Railtie
    railtie_name :my_plugin

    rake_tasks do
      load "tasks/my_plugin.rake"
    end
  end
end
&lt;/pre&gt;In this file we create a railtie class inside of our module, our new class has to be a descendant of the Rails::Railtie class. The 'rake_tasks' method is defined in the Rails::Railtie class, it takes a block that it then runs during the initialization of the rake environment in your app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;lib/tasks/my_plugin.rake&lt;/b&gt; &lt;br /&gt;
&lt;pre&gt;desc 'my plugins rake task'
task :do_something do
  puts "the rake task did something"
end
&lt;/pre&gt;Just a really simple rake task.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Using your new rake task&lt;/b&gt;&lt;br /&gt;
After you have built your gem and included it in your rails app using bundler the task is integrated just like any of the default rails tasks.&lt;br /&gt;
&lt;pre&gt;$ rake -T
# ...
# rake doc:rerails    # Force a rebuild of the RDOC files
# rake do_something   # my plugins rake task
# ...

$ rake do_something
# the rake task did something
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;Resources&lt;/b&gt;&lt;br /&gt;
&lt;a href="http://weblog.rubyonrails.org/2010/2/9/plugin-authors-toward-a-better-future"&gt;http://weblog.rubyonrails.org/2010/2/9/plugin-authors-toward-a-better-future&lt;/a&gt;&lt;br /&gt;
&lt;a href="https://gist.github.com/af7e572c2dc973add221"&gt;https://gist.github.com/af7e572c2dc973add221&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-9159619578669516147?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/9159619578669516147/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=9159619578669516147" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/9159619578669516147?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/9159619578669516147?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2010/02/rails-3-loading-rake-tasks-from-gem.html" title="Rails 3: Loading rake tasks from a gem" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>5</thr:total></entry><entry gd:etag="W/&quot;CEUNRnw9eip7ImA9WxBWFUU.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-4363293354562202109</id><published>2010-02-07T14:37:00.000-08:00</published><updated>2010-02-07T14:38:17.262-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-07T14:38:17.262-08:00</app:edited><title>Rails 3 beta: First impressions on a new app</title><content type="html">&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: Arial;"&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="Apple-style-span" style="font-family: Arial;"&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;Initial application creation&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="Apple-style-span" style="font-family: Arial;"&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;Initial application creation is as easy as it has always been. The output is formatted a little better and you can create an app with a path instead of just a subdirectory name. A .gitignore file is created automatically as well as a few .gitkeep files on directories that don't start out with files in them, a really nice touch for those of us who use git.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: Arial; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px; font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;script/* replaced by script/rails&lt;/b&gt;&lt;br /&gt;
This takes a little getting used to if you are used to the old script commands. Stuff like &lt;i&gt;"script/console"&lt;/i&gt; doesn't work any more, it has been replaced by "&lt;i&gt;rails console"&lt;/i&gt;&amp;nbsp;or &lt;i&gt;"rails c"&lt;/i&gt;&amp;nbsp;if you prefer the shorthand version.&amp;nbsp;&lt;i&gt;"rails --help"&lt;/i&gt;&amp;nbsp;will be your friend until you get used to the new commands.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Generators&lt;/b&gt;&lt;br /&gt;
The new generator system seems to be very well thought out and has all kinds of great new features if you want to modify templates or write your own generators. Even if you are just running the default generators things have improved a bit. The default templates have improved, for example div tags instead of p tags and use of a form partial instead of duplicating code in the edit and new views.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Testing&lt;/b&gt;&lt;br /&gt;
Testing out of the box does not seem to have changed much. The main thing I noticed is that most of the major testing tools are not yet working with the rails 3 beta. I tried out shoulda, rspec, and cucumber all without success.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-4363293354562202109?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/4363293354562202109/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=4363293354562202109" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/4363293354562202109?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/4363293354562202109?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2010/02/rails-3-beta-first-impressions-on-new.html" title="Rails 3 beta: First impressions on a new app" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>3</thr:total></entry><entry gd:etag="W/&quot;CEAASXo7fip7ImA9WxBREEw.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-3897808182576235861</id><published>2009-12-28T07:00:00.000-08:00</published><updated>2009-12-28T07:05:48.406-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-28T07:05:48.406-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="methods" /><category scheme="http://www.blogger.com/atom/ns#" term="update_attribute" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><title>Interesting Rails Methods: update_attribute</title><content type="html">&lt;span style="font-weight:bold;"&gt;Method:&lt;/span&gt; update_attribute&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Module:&lt;/span&gt; ActiveRecord::Base&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Documentation:&lt;/span&gt; Updates a single attribute and saves the record without going through the normal validation procedure. This is especially useful for boolean flags on existing records.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Notes:&lt;/span&gt;&lt;br /&gt;This method actually does far more than just update an attribute. It updates the whole object without validations. This is fine if you just retrieved the object from the database but it can be a disaster if you have modified other attributes on the object. &lt;br /&gt;&lt;br /&gt;Given:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Article.find(1)&lt;br /&gt;#&amp;lt;Article id:1 title:"title" body:"first article"&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Safe usage of update attribute:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;article = Article.find(1)&lt;br /&gt;article.update_attribute(:title, "new title")&lt;br /&gt;Article.find(1)&lt;br /&gt;#&amp;lt;Article id:1 title:"new title" body:"first article"&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Unsafe usage of update attribute:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;article = Article.find(1)&lt;br /&gt;article.body = ""&lt;br /&gt;article.update_attribute(:title, "new title")&lt;br /&gt;Article.find(1)&lt;br /&gt;#&amp;lt;Article id:1 title:"new title" body:""&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-3897808182576235861?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/3897808182576235861/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=3897808182576235861" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/3897808182576235861?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/3897808182576235861?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2009/12/interesting-rails-methods.html" title="Interesting Rails Methods: update_attribute" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkMBRHc-cCp7ImA9WxNXGUo.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-4565985238742506032</id><published>2009-10-07T22:00:00.000-07:00</published><updated>2009-10-07T22:07:35.958-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-10-07T22:07:35.958-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="code quality" /><category scheme="http://www.blogger.com/atom/ns#" term="gems" /><title>4 Ruby gems that will improve your rails app</title><content type="html">&lt;div&gt;These four gems have helped my team improve the quality of our code. We weren't writing bad code before but these tools made it possible for us to take our code to the next level. &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span  style="font-size:large;"&gt;&lt;b&gt;&lt;a href="http://ruby.sadi.st/Flog.html"&gt;Flog&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;Flog helps you analyze the complexity of your methods. It looks at the number of assignments, branches, and calls in a method and creates a complexity score for each method. The lower the score the less complex the method is, generally making it easier to read, test, and refactor.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span  style="font-size:large;"&gt;&lt;b&gt;&lt;a href="http://ruby.sadi.st/Flay.html"&gt;Flay&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;Flay analyzes code for duplication. It looks for structural similarities so things like variable names and whitespace won't keep it from detecting duplication in your code. &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span  style="font-size:large;"&gt;&lt;b&gt;&lt;a href="http://roodi.rubyforge.org/"&gt;Roodi&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;Roodi parses your code and gives warnings on several different code design issues. Roodi includes a few different measures of code complexity such as &lt;a href="http://en.wikipedia.org/wiki/Cyclomatic_complexity"&gt;cyclomatic complexity&lt;/a&gt;, line count, and parameter count as well as some useful &lt;a href="http://en.wikipedia.org/wiki/Lint_(software)"&gt;lint&lt;/a&gt; style checks.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:large;"&gt;&lt;b&gt;&lt;a href="http://github.com/relevance/rcov"&gt;Rcov&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;Rcov is a code coverage tool for ruby, it shows you what code was run during your tests. While that doesn't guarantee that you tested all of your boundary conditions it does go a long ways in giving you confidence in your test coverage. My teams threshold for code coverage is 100%, anything less is treated the same as a failing test. If you are planning on using rcov with a rails app I would suggest the &lt;a href="http://blog.codahale.com/2006/05/26/rails-plugin-rails_rcov/"&gt;rails_rcov&lt;/a&gt; plugin.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Bonus FREE rails plugin&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;When my team runs tests on our apps we use &lt;a href="http://github.com/nathanhumbert/rails_quality"&gt;rails_quality&lt;/a&gt; a plugin I wrote that runs all four of these gems during the testing process. Any output that is outside of the thresholds we have set is treated the same as a failing test. I would recommend this practice to anyone. It will make your code better and it pays off way earlier in the development cycle than you expect.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-4565985238742506032?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/4565985238742506032/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=4565985238742506032" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/4565985238742506032?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/4565985238742506032?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2009/10/4-ruby-gems-that-will-improve-your.html" title="4 Ruby gems that will improve your rails app" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;D08ARHs4fCp7ImA9WxRWFE4.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-8911258303227121304</id><published>2008-10-30T23:50:00.000-07:00</published><updated>2008-10-30T23:50:45.534-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-10-30T23:50:45.534-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="queue" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="mongrel" /><category scheme="http://www.blogger.com/atom/ns#" term="upgrade" /><title>Upgrading rails apps without downtime</title><content type="html">I recently worked on an application that took messages from internal applications and queued them up before sending them to an external vendor. The application was built because the messages were important enough that loosing any messages sent during vendor downtime was not an option. Since all applications involved were using rails it was an obvious choice to develop the queuing app in rails and use a REST api to transfer the data into the queue.&lt;br /&gt;&lt;br /&gt;The queue app went together quite nicely and everything was going smoothly until it went live and updates were needed to fix some bugs. Since the queuing app was the method for handling downtime outside of the main application it wasn't safe for the queue to go down while the main application was still up. Out of necessity I quickly came up with a solution.&lt;br /&gt;&lt;br /&gt;The final solution consists of running more than one mongrel cluster, preferably on different servers. Proxy to all of those clusters from the apache instance that is serving the main application. This provides redundancy as far as the mongrel clusters are concerned and if the main apps apache server is down the application won't be generating any messages to be queued.&lt;br /&gt;&lt;br /&gt;To upgrade the queuing app without downtime upgrade the code behind one of the clusters and restart that cluster, repeating until all clusters have been upgraded. This works very nicely, but it does require careful development to ensure that each update is compatible with the previous version of the application.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-8911258303227121304?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/8911258303227121304/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=8911258303227121304" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/8911258303227121304?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/8911258303227121304?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2008/10/upgrading-rails-apps-without-downtime.html" title="Upgrading rails apps without downtime" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CEEGQn87fyp7ImA9WxRSFEw.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-200666448344680673</id><published>2008-09-14T10:17:00.000-07:00</published><updated>2008-09-14T10:17:03.107-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-09-14T10:17:03.107-07:00</app:edited><title>Using inject/reduce to create hashes in ruby</title><content type="html">I have been using map and reduce/inject (reduce is the new name for inject in ruby) quite a bit lately and learning quite a bit in the process. Map was pretty easy, inject on the other hand has been giving me some trouble. Recently I have been playing around with using inject with hashes, what follows is some of what I learned.&lt;br /&gt;&lt;br /&gt;Given the following structure:&lt;br /&gt;&lt;pre&gt;old_structure = [['username', 'bob'], ['password','secret']]&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Converting to the following more appropriate structure can be done several ways:&lt;br /&gt;&lt;pre&gt;new_structure = {'username' =&gt; 'bob',  'password' =&gt; 'secret'}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Method 1:&lt;/b&gt; Without using inject&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;new_structure = {}&lt;br /&gt;old_structure.each do |element|&lt;br /&gt; hash[element[0]] = element[1]&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Method 2:&lt;/b&gt; Using inject&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;new_structure = old_structure.inject({}) do |results, element|&lt;br /&gt; results[element[0]] = element[1]&lt;br /&gt; results&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Method 3:&lt;/b&gt; Using inject with a little cleaner syntax&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;new_structure = old_structure.inject({}) do |results, element|&lt;br /&gt; results.merge( { element[0] =&gt; element[1] } )&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-200666448344680673?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/200666448344680673/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=200666448344680673" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/200666448344680673?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/200666448344680673?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2008/09/using-injectreduce-to-create-hashes-in.html" title="Using inject/reduce to create hashes in ruby" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>2</thr:total></entry><entry gd:etag="W/&quot;CUAAQX88cCp7ImA9WxdaGEw.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-3348151587256470051</id><published>2008-08-26T22:09:00.000-07:00</published><updated>2008-08-26T22:09:00.178-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-26T22:09:00.178-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="dirty objects" /><category scheme="http://www.blogger.com/atom/ns#" term="password" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><title>Easy password hashing in rails 2.1</title><content type="html">I was working on a simple authentication system for a new project and got to the point where I needed to hash the password before storing it. I realized that this was a great opportunity to use the new dirty objects functionality that came out in rails 2.1.&lt;br /&gt;&lt;br /&gt;First off, a quick explanation of dirty objects. Dirty objects provides the ability to tell what attributes of a model object have changed. For example, given an active record object "foo" with an attribute "bar", dirty objects adds a method "foo.bar_changed?" which returns true if  the attribute "foo.bar" has been changed since the object "foo" was pulled from the database.&lt;br /&gt;&lt;br /&gt;In the past when changing a password there has never been a really simple/elegant way to detect when the password had been changed and only then, hash the password. Now it is trivially simple. Adding the following few lines of code to the model does the job quite nicely.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;after_validation :hash_password&lt;br /&gt;&lt;br /&gt;def hash_password&lt;br /&gt; if self.password_changed?&lt;br /&gt;   self.password = Digest::MD5.hexdigest(self.password)&lt;br /&gt; end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;Now, whenever the password in the object is modified, whether it is via a form submission or just updating the object in script/console, save the object and the password will be hashed before it is stored. If there are any validations that don't pass the object will not be saved and the password will be the same as it had been.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-3348151587256470051?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/3348151587256470051/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=3348151587256470051" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/3348151587256470051?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/3348151587256470051?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2008/08/easy-password-hashing-in-rails-21.html" title="Easy password hashing in rails 2.1" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUIEQXk8eCp7ImA9WxdaE0U.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-8339486787043256525</id><published>2008-08-21T20:01:00.000-07:00</published><updated>2008-08-21T22:38:20.770-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-21T22:38:20.770-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="plugins" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="gems" /><title>Choosing good gems/plugins for your rails app</title><content type="html">Over the past few months I have been working on upgrading some of the rails applications I have been working on. I have been having quite a bit of trouble and a large portion of the issues stem from the gems and plugins that were used. In the past I have not had that much trouble with plugins and gems making upgrades difficult, so I sat down and tried to come up with some guidelines for picking plugins. These are the guidelines I came up with.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;My plugin/gem selection guidelines:&lt;/span&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Does it have a well defined goal?&lt;/li&gt;&lt;li&gt;Does it do something substantial?&lt;/li&gt;&lt;li&gt;Does it have a good record?&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-weight: bold;"&gt;Does the plugin/gem have a well defined goal?&lt;/span&gt;&lt;br /&gt;If the plugin you are evaluating does everything, that isn't necessarily a good thing. A plugin that does everything will likely to be harder to debug and has a higher chance of conflicting with something. A plugin that does one thing has a much better chance of doing that one thing very well.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Does the plugin/gem do something substantial?&lt;/span&gt;&lt;br /&gt;If the task at hand is pretty simple it may be better to write the code yourself. When you are faced with a rails update, maintaining a few extra lines of code could end up being a lot easier than finding the latest version of the plugin and making sure the new version is compatible with your application.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Does the plugin/gem have a good record?&lt;/span&gt;&lt;br /&gt;Does the plugin appear to be well maintained or has it been years since it was updated? Does it only have one contributor  or does it have a good community built around it?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example 1: Chronic &lt;/span&gt;&lt;a href="http://chronic.rubyforge.org/"&gt;(chronic.rubyforge.org)&lt;/a&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Does Chronic have a well defined goal?&lt;/span&gt;&lt;br /&gt;Yes,&lt;span&gt; Chronic &lt;/span&gt;is a natural language date/time parser.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Does Chronic do something substantial?&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;Yes, it would take a lot of work to write a natural language date/time parser.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Does Chronic have a good record?&lt;/span&gt;&lt;br /&gt;It looks pretty good, it has been around for a couple years, quite a few people seem to be using it, and it has survived several rails upgrades without big issues.&lt;br /&gt;&lt;br /&gt;Looks like Chronic meets the guidelines fairly well. I have been using Chronic quite successfully for about a year and a half.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example 2: Facets &lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;a href="http://facets.rubyforge.org/"&gt;(facets.rubyforge.org)&lt;/a&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Does Facets have a well defined goal?&lt;/span&gt;&lt;br /&gt;No, it is an attempt to do just about everything.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Does Facets do something substantial?&lt;/span&gt;&lt;br /&gt;Not really, it does a lot, but it is made up of lots of little pieces.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Does Facets have a good record?&lt;/span&gt;&lt;br /&gt;Yes and no, it has a substantial community behind it which is good, it has been around for a little while which is good, but it has also had some very large structural changes which made different versions incompatible.&lt;br /&gt;&lt;br /&gt;Looks like Facets doesn't meet the guidelines, based on that I would not choose to use Facets in one of my rails apps.&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;span style="font-size:100%;"&gt;Facets is a gem that came built into some apps that I work with, I have had a lot of problems with Facets and how it was used.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example 3: file-tail &lt;/span&gt;&lt;a href="http://file-tail.rubyforge.org/"&gt;(file-tail.rubyforge.org)&lt;/a&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Does file-tail have a well defined goal?&lt;/span&gt;&lt;br /&gt;Yes, it allows you to tail a file without having process the output of a system tail application.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Does file-tail do something substantial?&lt;/span&gt;&lt;br /&gt;Yes, it would be a bit of work to write your own tail library in ruby.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Does file-tail have a good record?&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Yes and no, it has been around for quite some time and seems to be very stable, but it doesn't have a big community and I haven't found many people that talk about using it.&lt;br /&gt;&lt;br /&gt;File-tail doesn't meet all the guidelines perfectly but it should be reasonably safe. I recently used File-tail in an application and it has performed very well so far.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-8339486787043256525?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/8339486787043256525/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=8339486787043256525" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/8339486787043256525?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/8339486787043256525?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2008/08/choosing-good-gemsplugins-for-your.html" title="Choosing good gems/plugins for your rails app" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DUcMRn8-fip7ImA9WxdbFUw.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-7739557864144237613</id><published>2008-08-11T21:17:00.000-07:00</published><updated>2008-08-11T21:58:07.156-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-11T21:58:07.156-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="csv" /><category scheme="http://www.blogger.com/atom/ns#" term="excel" /><category scheme="http://www.blogger.com/atom/ns#" term="bug" /><category scheme="http://www.blogger.com/atom/ns#" term="microsoft" /><title>Issue with CSV files and excel</title><content type="html">I ran into an interesting bug with MS excel the other day. Turns out several versions of excel have issues with CSV files which have ID in capital letters as the first two characters of the file. Excel throws an error, "SYLK: File format is not valid". &lt;br /&gt;&lt;br /&gt;One of my coworkers ran into the error when they tried to open a report I had sent them. It took a bit of time to track down, and made me question my ability to generate CSV files for a little while, but at least it was an easy fix. I just changed the first two characters "ID" to "id". &lt;br /&gt;&lt;br /&gt;The two things I thought was really entertaining about this bug are first, you can export an excel file which had "ID" in the first cell to create an invalid SYLK file and second SYLK files are a Microsoft file format.&lt;br /&gt;&lt;br /&gt;If you are interested in some more details here are a couple reference links:&lt;br /&gt;&lt;a href="http://support.microsoft.com/kb/323626"&gt;Microsoft Support page&lt;/a&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/SYmbolic_LinK_(SYLK)"&gt;Wikipedia article on SYLK files&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-7739557864144237613?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/7739557864144237613/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=7739557864144237613" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/7739557864144237613?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/7739557864144237613?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2008/08/issue-with-csv-files-and-excel.html" title="Issue with CSV files and excel" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUINSHgzfip7ImA9WxdbFE0.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-5794334725753580887</id><published>2008-06-14T12:30:00.000-07:00</published><updated>2008-08-10T14:26:39.686-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-10T14:26:39.686-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="routing" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><title>Using rails routing for easy search engine friendly URL changes</title><content type="html">&lt;p&gt;&lt;br /&gt;In this entry I am going to show how to, in a very search engine friendly way, update a URL for a particular page in a rails website. The rails routing system provides named routes, which are a very nice way to change the URL for a particular page and have all of your links update without having to change code in a bunch of different places. That is a great start on moving a page, but it doesn't take care of any links from outside of your site that might be pointing at the old URL. The best way to handle that is to make it so that the old URL redirects to the new URL, your end users won't notice a difference but the search engines bots will take note and update their indexes.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;First off if you are not familiar with routing and named routes in rails you might want to read up on it. The &lt;a href="http://api.rubyonrails.org/"&gt;rails API docs&lt;/a&gt; have some pretty good material on routes located at &lt;a href="http://api.rubyonrails.org/classes/ActionController/Routing.html"&gt;http://api.rubyonrails.org/classes/ActionController/Routing.htm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Lets pretend we are moving "http://example.com/users/signup" to "http://example.com/signup". Our original named route might look something like this:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;map.signup '/users/signup', :controller =&gt; 'users', :action =&gt; 'signup'&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And the code for a link that pointed to it would look something like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;%= link_to 'Signup', signup_url %&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To change our URL we would simply change the named route to look like this:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;map.signup '/signup', :controller =&gt; 'users', :action =&gt; 'signup'&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;All of the links that used the named route would automatically change to link to the new URL but the old URL would stop working. To change that we could add the following to the routes file&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;map.signup_old '/users/signup', :controller =&gt; 'users', :action =&gt; 'signup', :old_url =&gt; true&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This would allow the old URL to work, but it would be best if we made it so that it redirected to the new URL so that search engines would switch over to the new URL faster. Notice that there is an additional parameter that is defined on the end of the second route, this makes it so that we can easily differentiate what URL a visitor arrived on the page with.&lt;br /&gt;&lt;br /&gt;Now all we have to do is make a method we can use in a before filter that redirects the user to the same action, the redirect will automatically use the first route we defined (as long as we leave them in that order in the routes file). In the users controller we would add the following code:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;before_filter :redirect_to_new_url&lt;br /&gt;&lt;br /&gt;def redirect_to_new_url&lt;br /&gt;if params[:old_url] == true&lt;br /&gt;  headers["Status"] = "301 Moved Permanently"&lt;br /&gt;  redirect_to({:action =&gt; action_name})&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;The lines in the route file would look like this:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;map.signup '/signup', :controller =&gt; 'users', :action =&gt; 'signup'&lt;br /&gt;map.signup_old '/users/signup', :controller =&gt; 'users', :action =&gt; 'signup', :old_url =&gt; true&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Once you have this in place you only have to add a new route to move a URL in a search engine friendly way, and when you decide that all the external links and search engines are updated all you have to do is get rid of the route that points to the old URL.&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-5794334725753580887?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/5794334725753580887/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=5794334725753580887" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/5794334725753580887?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/5794334725753580887?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2008/08/using-rails-routing-for-easy-search.html" title="Using rails routing for easy search engine friendly URL changes" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUEHQH08fyp7ImA9WxdbFE0.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-5114480753243609353</id><published>2008-06-01T12:29:00.000-07:00</published><updated>2008-08-10T14:27:11.377-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-10T14:27:11.377-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="dry" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><title>What DRY is really about</title><content type="html">&lt;p&gt;&lt;br /&gt;Lets start with what the acronym DRY stands for, Do not Repeat Yourself. That sounds like a pretty good idea, it makes sense, but what are we really trying to accomplish by keeping our code DRY? Ok, that was a rhetorical question but I know someone out there would probably respond by saying "Not repeating ourselves!", to which the audience would chuckle because everyone knows that isn't what DRY is about. DRY is really about making high quality maintainable code.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Lately I have been finding things in the code base that I am working with that indicates that some programmers have taken DRY way too literally and use it in places that reduce code readability and maintainability.  For example I found something similar to the following ruby on rails code a while back.&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;if something == true&lt;br /&gt; temp_var = {:action =&gt; "foo"}&lt;br /&gt;else&lt;br /&gt; temp_var = {:action =&gt; "bar"}&lt;br /&gt;end&lt;br /&gt;redirect_to {:controller =&gt; "main"}.merge(temp_var)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In this example of code, they are essentially avoiding a tiny bit of duplication, defining the controller. The thing is this code is more difficult to understand than the following.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;if something == true&lt;br /&gt; redirect_to :controller =&gt; "main", :action =&gt; "foo"&lt;br /&gt;else&lt;br /&gt; redirect_to :controller =&gt; "main", :action =&gt; "bar"&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In the second example there is a slight bit of duplication, but it is also easier to figure out what the code is doing as you read through your if statement. That increased readability makes the code just a little easier to maintain. Additionally if you were thinking about changing this code there is a good chance that you would be changing the controller argument for only one of the two redirect calls, in which case the second code example is much simpler to edit. Of course there is another option, if the person writing this code originally had been aware of some additional functionality that the rails framework offers they would have used a named route which would get rid of all of the duplication while maintaining great code readability.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;if something == true&lt;br /&gt; redirect_to foo_url&lt;br /&gt;else&lt;br /&gt; redirect_to bar_url&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now that you know DRY isn't just about not repeating yourself, take a little extra time before removing duplication and think about whether the change gets you closer to the goal of having readable and maintainable code. If the change doesn't make your code easier to maintain consider leaving the duplication or even better do some research and find a solution that gets rid of the duplication without making things harder to read or maintain.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-5114480753243609353?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/5114480753243609353/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=5114480753243609353" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/5114480753243609353?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/5114480753243609353?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2008/08/what-dry-is-really-about.html" title="What DRY is really about" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUEBQH05fSp7ImA9WxdbFE0.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-7310743131286332922</id><published>2008-01-31T12:27:00.000-08:00</published><updated>2008-08-10T14:27:31.325-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-10T14:27:31.325-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="plugin" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="email" /><title>My first open source rails plugin: SafeDevEmail</title><content type="html">&lt;p&gt;&lt;br /&gt;I just finished up the initial version of my first open source rails plugin. It is a fairly simple plugin which allows you to configure an email address that will receive all emails sent from your rails app while it is in development mode.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;The plugin is available at &lt;a href="http://code.google.com/p/safedevemail/"&gt;code.google.com/p/safedevemail/&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;To get started all you need to do is drop the plugin in your vendor/plugins directory and edit your mailserver settings in evironment.rb&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Config Examples:&lt;/h3&gt;&lt;h4&gt;SMTP&lt;/h4&gt;&lt;pre&gt;&lt;br /&gt;ActionMailer::Base.smtp_settings = {&lt;br /&gt; :address  =&gt; "smtp.example.com",&lt;br /&gt; :port  =&gt; 25,&lt;br /&gt; :domain  =&gt; "www.mywebsite.com",&lt;br /&gt; :dev_mailto =&gt; "developer@mywebsite.com"&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;h4&gt;Sendmail&lt;/h4&gt;&lt;pre&gt;&lt;br /&gt;ActionMailer::Base.sendmail_settings = {&lt;br /&gt; :dev_mailto =&gt; "developer@mywebsite.com"&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-7310743131286332922?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/7310743131286332922/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=7310743131286332922" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/7310743131286332922?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/7310743131286332922?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2008/08/my-first-open-source-rails-plugin.html" title="My first open source rails plugin: SafeDevEmail" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUECRno5cSp7ImA9WxdbFE0.&quot;"><id>tag:blogger.com,1999:blog-2034294260974008111.post-3358619181682741570</id><published>2008-01-17T12:13:00.000-08:00</published><updated>2008-08-10T14:27:47.429-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-10T14:27:47.429-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="activerecord" /><category scheme="http://www.blogger.com/atom/ns#" term="migrations" /><title>Lazy Migrations</title><content type="html">&lt;p&gt;&lt;br /&gt;I was working on &lt;a href="http://www.americanwinery.com"&gt;americanwinery.com&lt;/a&gt; and one of my coworkers asked me about a model that they hadn't seen before. Turns out it was from the early days of the site and it was never even used in production. It was a great candidate for a little code cleanup, so I removed the model and tests and started in on the migration to remove the table.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;When I write migrations I generally make a point of making them reversible, so as I was looking for the original migration to copy the structure of the table I thought it would be much easier to just call the "up" from the original migration in the "down" of the migration I was working on. It was an interesting thought, turns out it is pretty easy to do.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;For example, lets say you have a migration that creates a table named articles and it looks something like this:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;class CreateArticles &lt; ActiveRecord::Migration&lt;br /&gt;  def self.up&lt;br /&gt;    create_table :articles do |t|&lt;br /&gt;      t.text :title, :body&lt;br /&gt;      t.timestamps&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def self.down&lt;br /&gt;    drop_table :articles&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;A few days/months/years later you realize that you don't use that table and you decide to write a migration to get rid of it, here is what I would suggest:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;class DropArticles &lt; ActiveRecord::Migration&lt;br /&gt;  def self.up&lt;br /&gt;    CreateArticles.migrate("down")&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def self.down&lt;br /&gt;    CreateArticles.migrate("up")&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;That is all there is to it. If you want to do a little more reading on this subject you can check out the &lt;a href="http://api.rubyonrails.org/classes/ActiveRecord/Migration.html"&gt;API documentation (http://api.rubyonrails.org/classes/ActiveRecord/Migration.html)&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2034294260974008111-3358619181682741570?l=blog.nathanhumbert.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.nathanhumbert.com/feeds/3358619181682741570/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2034294260974008111&amp;postID=3358619181682741570" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/3358619181682741570?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2034294260974008111/posts/default/3358619181682741570?v=2" /><link rel="alternate" type="text/html" href="http://blog.nathanhumbert.com/2008/08/lazy-migrations.html" title="Lazy Migrations" /><author><name>Nathan</name><uri>http://www.blogger.com/profile/16997206987454453016</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry></feed>

