<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Martinicity: Tag rails</title>
    <link>http://martinicity.net/articles_controller.rb/tag?tag=rails</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Mike Blake</description>
    <item>
      <title>The Philanthropic Programmers</title>
      <description>&lt;p&gt;Something fantastic is happening in the &lt;a href="http://www.rubyonrails.org/"&gt;Ruby and  Rails&lt;/a&gt; World.&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/ruby_shades.jpg" alt=""/&gt;&lt;/p&gt;

&lt;h3&gt;Do unto others&lt;/h3&gt;

&lt;p&gt;Open source developers know from experience that what goes around comes around.   Contributions to projects like Rails invariably come back to benefit everyone, including the contributor.  The community is now thinking on a larger scale.  Frameworks come and go, but &lt;a href="http://pragdave.pragprog.com/pragdave/2007/05/rails_is_love.html"&gt;love&lt;/a&gt; is timeless .&lt;/p&gt;

&lt;h3&gt;The Summer of Love&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://whytheluckystiff.net/"&gt;Whytheluckystiff&lt;/a&gt; is focusing his power on &lt;a href="http://hacketyhack.net/"&gt;Hackety Hack&lt;/a&gt; an amazing application that teaches children programming.  And  it&amp;#8217;s likely more zeitgeist than coincidence that a professor from MIT, where the generous open source license originated, has started the noble project called &lt;a href="http://laptop.org"&gt;One Laptop per Child&lt;/a&gt; . Developers everywhere like &lt;a href="http://slash7.com/articles/2006/4/17/teaching-rails-for-charity-in-d-c"&gt;Amy Hoy&lt;/a&gt;  are giving back in order to share the passion. &lt;/p&gt;

&lt;p&gt;&lt;img src="/images/rails_logo_heart.png" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;Chad Fowler has challenged the entire community to harness our newfound passion to do &lt;a href="http://www.chadfowler.com/2007/5/19/changing-the-world"&gt;great things&lt;/a&gt;.  And the community has only just begun to respond. During RailsConf over &lt;a href="http://www.clarkware.com/cgi/blosxom/2007/05/22#RailsConf07"&gt;$33,000&lt;/a&gt; was raised for &lt;a href="http://pragmaticstudio.com/donate/"&gt;charity&lt;/a&gt;. &lt;/p&gt;

&lt;h3&gt;&lt;a href="http://www.lse.co.uk/ShowbizNews.asp?Code=WV31893G&amp;amp;headline=paris_hilton_shortlisted_for_nun_role"&gt;Witness the Transformation&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Software evolves rapidly.   Humanity seems to evolve at a slower pace, but if you watch carefully, with ruby colored glasses , you can see it happening. &lt;/p&gt;</description>
      <pubDate>Tue, 22 May 2007 21:16:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:5cbbdb9a-35d6-4c26-aed0-fdf039d89942</guid>
      <author>Mike Blake</author>
      <link>http://martinicity.net/articles/2007/05/22/the-philanthropic-programmers</link>
      <category>Create</category>
      <category>Pray</category>
      <category>ruby</category>
      <category>rails</category>
      <category>love</category>
    </item>
    <item>
      <title>Hibernate 3.x Migration Guide</title>
      <description>&lt;h4&gt;Update 4/30&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;
I finally did find the real &lt;a href="http://www.hibernate.org/250.html"&gt;Hibernate 3 Migration Guide&lt;/a&gt;. My fun with Hibernate is over though, I've found an easier persistence solution with the clients  homegrown method. I believe every single java project I've worked on in the past 10 years has used a different and unique Persistence mechanism.  My favorite was &lt;a href="http://www.eclipsecon.org/2007/index.php?page=presenters/#Francois_Granade"&gt;Francois'&lt;/a&gt; PersistentEntity at ViaFone.
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;p /&gt;
&lt;hr /&gt;
I&amp;#8217;ve been strugling for the last day trying to get a Java application working, mainly, trying to get Hibernate to see a DataSource.  Now I&amp;#8217;m at a point where I get this error message: &lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;[junit] (cfg.Configuration                   1312) configuring from resource: /hibernate.cfg.xml&lt;/p&gt;
    
    &lt;p&gt;[junit] (cfg.Configuration                   1289) Configuration resource: /hibernate.cfg.xml&lt;/p&gt;
    
    &lt;p&gt;[junit] (util.DTDEntityResolver              30  ) Don&amp;#8217;t use old DTDs, read the &lt;strong&gt;Hibernate 3.x Migration Guide!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A quick search does not turn up a Hibernate Migration Guide, so I decided to create this one.&lt;/p&gt;

&lt;h1&gt;The Hibernate 3.x Migration Guide&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Get &lt;a href="http://www.ruby-lang.org/en/"&gt;Ruby&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install &lt;a href="http://www.rubyonrails.org/down"&gt;Rails&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Rebuild your application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Have fun again!&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;</description>
      <pubDate>Thu, 26 Apr 2007 11:30:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:4211efe2-2393-422e-af13-478696806a85</guid>
      <author>Mike Blake</author>
      <link>http://martinicity.net/articles/2007/04/26/hibernate-3-x-migration-guide</link>
      <category>Create</category>
      <category>ruby</category>
      <category>rails</category>
      <category>hibernate</category>
      <category>migration</category>
      <trackback:ping>http://martinicity.net/articles/trackback/889</trackback:ping>
    </item>
    <item>
      <title>Testing a Non-Rails Application Using Rails</title>
      <description>&lt;p&gt;Rails developers working on enterprise software projects are suprised to discover the lack of automated tests in many mature web applications. As frustrating as this can be, A lack of automated tests is also a tremendous opportunity to &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Learn your non-rails applications underlying database structure.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Demonstrate to a devlopment team the power of The Rails Framework.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Encourage automated testing.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Rails may be the quickest path to automate some basic test of your non-rails applications data model. These steps will get you all set up to write your automated tests in Ruby.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="#connect"&gt;Connect to Your Enterprise Database&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#conventions"&gt;Set DB Conventions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#safety"&gt;Safety Net&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#schema"&gt;Duplicate the Schema&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#extract"&gt;Extract Development Data&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id='connect'&gt;I. Connect to Your Enterprise Database from Rails.&lt;/h4&gt;

&lt;p&gt;&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Download and install any os driver, ruby gems, and rails adapters needed to connect to your database:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://wiki.rubyonrails.com/rails/pages/DatabaseDrivers"&gt;Supported Rails Databases&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;&lt;a href="http://wiki.rubyonrails.com/rails/pages/MySQL"&gt;MySQL&lt;/a&gt;
    &lt;br&gt;&lt;a href="http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0606dumbill/?ca=dgr-lnxw01DB24RubyonRails"&gt;DB2&lt;/a&gt;
    &lt;br&gt;&lt;a href="http://www.oracle.com/technology/pub/articles/saternos-ror-faq.html"&gt;Oracle&lt;/a&gt;
    &lt;br&gt;&lt;a href="http://wiki.rubyonrails.org/rails/pages/HowToSetupSybaseAdapterOnRails"&gt;Sybase&lt;/a&gt;
    &lt;br&gt;&lt;a href="http://wiki.rubyonrails.org/rails/pages/HowtoConnectToMicrosoftSQLServer"&gt;SQLServer&lt;/a&gt;
    &lt;br&gt;&lt;a href="http://wiki.rubyonrails.org/rails/pages/PostgreSQL"&gt;PostgreSQL&lt;/a&gt;
    &lt;br&gt;&lt;a href="http://wiki.rubyonrails.org/rails/pages/Firebird"&gt;Firebird&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4 id='conventions'&gt;II. Set Your Existing Database Conventions &lt;/h4&gt;

&lt;p&gt;&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.pragmaticprogrammer.com/titles/fr_rr/"&gt;Rails Recipes&lt;/a&gt;
, Recipie #16 can walk you through this very quickly.&lt;/p&gt;

&lt;p&gt;Identify any conventions used by your legacy database.  Application wide conventions can be set in the &lt;code&gt;config/environment.rb&lt;/code&gt; file.
They are specified by calling the appropriate class methods available on &lt;a href="http://api.rubyonrails.org/classes/ActiveRecord/Base.html"&gt;ActiveRecord::Base&lt;/a&gt;. The methods you need to call depend on how your database is configured:&lt;/p&gt;

&lt;pre&gt;
ActiveRecord::Base.table_name_prefix 'myapp_'
ActiveRecord::Base.table_name_suffix = '_def'
ActiveRecord::Base.sequence_name = 'dev_company'
ActiveRecord::Base.pluralize_table_names = false 
ActiveRecord::Base.primary_key_prefix_type = :table_name_with_underscore # or :table_name
&lt;/pre&gt;

&lt;h4 id='safety'&gt;III. Safety Net&lt;/h4&gt;

&lt;p&gt;&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Load the &lt;a href="http://agilewebdevelopment.com/plugins/safety_net"&gt;SafetyNet Plugin&lt;/a&gt; into your rails app to prevent from destroying your development database.&lt;/p&gt;

&lt;h4 id='schema'&gt;IV. Duplicate Your Database Schema&lt;/h4&gt;

&lt;p&gt;&lt;p&gt;&lt;/p&gt;

&lt;p&gt;OK , with your dev and test development databases set correctly, let&amp;#8217;s try duplicting the schema.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rake db:test:clone&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If this works right off the bat, you&amp;#8217;re one of the lucky ones. Skip to &lt;a href="#extract"&gt;Extracting Development Data&lt;/a&gt;
&lt;p&gt;&lt;/p&gt;

&lt;p&gt;If you recieved errors from the clone command, do steps A through C .&lt;/p&gt;

&lt;p&gt;A. You can now correct any errors you may have had by manually modifying schema.rb .  See &lt;a href="/articles/2007/03/29/rails-on-oracle"&gt;Oracle Errors&lt;/a&gt; for some problems I had with the Oracle Database. Since schema.rb is generated, it&amp;#8217;s a good idea to rename it when you modify it manually.&lt;/p&gt;

&lt;p&gt;B. The clone command above may have started loading data; you need may to purge  the test db.
&lt;code&gt;
rake db:test:purge
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;C. Tell rake to load your new schema file by passing the new name, relative to RAILS_ROOT in the SCHEMA environment variable:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
rake db:schema:load RAILS_ENV=test SCHEMA=db/oracle_schema.rb
&lt;/code&gt; &lt;/p&gt;

&lt;h4 id='extract'&gt;V. Extracting Development Data&lt;/h4&gt;

&lt;p&gt;&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Copy the code from 
Rails Recipe #42: &lt;a href="http://media.pragprog.com/titles/fr_rr/code/CreateFixturesFromLiveData/lib/tasks/extract_fixtures.rake"&gt;extract_fixtures.rake&lt;/a&gt; to your RAILS_ROOT/lib/tasks directory.&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;&lt;strong&gt;TIP: If your develoment database has lots of data, Modify the SQL Select in this code to limit the amount of data you copy using the SQL limit statement:&lt;/strong&gt;&lt;/p&gt;
    
    &lt;p&gt;&lt;code&gt;sql  = "SELECT * FROM %s limit = 100"&lt;/code&gt;&lt;/p&gt;
    
    &lt;p&gt;Or for a proprietary database, the equivalent command:&lt;/p&gt;
    
    &lt;p&gt;&lt;code&gt;sql  = "SELECT * FROM %s WHERE ROWNUM&amp;lt;=100"&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then run 
&lt;code&gt;
 rake extract_fixtures
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;p&gt;&lt;/p&gt;

&lt;h4&gt;You&amp;#8217;ve made your testbed so you can lie in it.&lt;/h4&gt;

&lt;p&gt;You now have and exact copy of your development database, and a collection of sample data in Yaml format, and are ready to begin writing some Unit Tests. Stay tuned for some examples. Rail on!
&lt;span&gt;&lt;/p&gt;

&lt;script type="text/javascript"&gt;
digg_url = 'http://martinicity.net/articles/2007/03/31/testing-a-non-rails-application-using-rails';
digg_title = 'Testing a Non-Rails Application Using Rails';&lt;/script&gt;

&lt;script src="http://digg.com/tools/diggthis.js" type="text/javascript"&gt;&lt;/script&gt;

&lt;p&gt;&lt;/span&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 31 Mar 2007 13:11:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:ae1917e2-4a47-4fa2-be71-d57109445b46</guid>
      <author>Mike Blake</author>
      <link>http://martinicity.net/articles/2007/03/31/testing-a-non-rails-application-using-rails</link>
      <category>Create</category>
      <category>rails</category>
      <category>ruby</category>
      <category>unit tests</category>
      <category>database</category>
      <category>yml</category>
      <category>rake</category>
    </item>
    <item>
      <title>Rails on Oracle</title>
      <description>&lt;p&gt;When rails on jruby and connecting to Oracle via JDBC ,the following error eventually appears:&lt;/p&gt;

&lt;p&gt;Update:
&lt;code&gt;
java.sql.SQLException: Io exception: Broken pipe
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You need a dedicated connection from Oracle. Change the url: line in database.yml from
&lt;code&gt;
  url: jdbc:oracle:thin:@localhost:1521:XE&lt;/p&gt;

&lt;p&gt;to&lt;/p&gt;

&lt;p&gt;url: jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS&lt;em&gt;LIST = (ADDRESS =(PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))) (CONNECT&lt;/em&gt;DATA =(SERVER = DEDICATED) (SID = XE)))
&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;Workarounds&lt;/h2&gt;

&lt;p&gt;Duplicating an existing Oracle Database using the build in task &lt;code&gt;rake db:test:clone&lt;/code&gt; presented a few problems. Here&amp;#8217;s what I did to work around them.&lt;/p&gt;

&lt;h3&gt;ORA-01727: numeric precision specifier is out of range&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;
OCIError: ORA-01727: numeric precision specifier is out of range (1 to 38): CREATE TABLE employee (id NUMBER(38) NOT NULL PRIMARY KEY, created&lt;em&gt;date DATE DEFAULT NULL, start&lt;/em&gt;date DATE DEFAULT NULL, job&lt;em&gt;id DECIMAL DEFAULT NULL, total&lt;/em&gt;hours NUMBER(126) DEFAULT NULL)
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For some reason whne rails dumps the schema, it reports Oracle type FLOAT as NUMBER(126), so you just need to changed that back to FLOAT if you want to import that schema.&lt;/p&gt;

&lt;h3&gt;OCIError: ORA-00972 identifier is too long:&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;
OCIError: ORA-00972: identifier is too long: CREATE SEQUENCE gametime_responsibility_ref_seq START WITH 10000
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Rails tries to create sequences in Oracle to handle AUTOINCREMENT id fields.  It uses TABLE&lt;em&gt;NAME = &amp;#8217;&lt;/em&gt;SEQ&amp;#8217; for the sequence name. If a sqequence name is too long then you have to shorten it in schema.rb .&lt;/p&gt;

&lt;h3&gt;OCIError: ORA-00907: missing right parenthesis&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;
OCIError: ORA-00907: missing right parenthesis: CREATE TABLE board (id NUMBER(38) NOT NULL PRIMARY KEY, name VARCHAR2(150) NOT NULL, name VARCHAR2(150) NOT NULL, parent VARCHAR2(150) DEFAULT NULL, log&lt;em&gt;level DECIMAL DEFAULT NULL, modified&lt;/em&gt;date DATE(6) DEFAULT NULL, token DECIMAL DEFAULT NULL) 
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For some reason Rails assigns Date fields a size in schema.rb .  You&amp;#8217;ll need to change all occurances of DATE(6) to DATE .&lt;/p&gt;</description>
      <pubDate>Thu, 29 Mar 2007 21:15:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:1fd946dc-17d2-40fd-abf8-2b4dd3474377</guid>
      <author>Mike Blake</author>
      <link>http://martinicity.net/articles/2007/03/29/rails-on-oracle</link>
      <category>Create</category>
      <category>rails</category>
      <category>oracle</category>
      <category>schema</category>
      <category>rb</category>
    </item>
    <item>
      <title>Undefined method assert_select</title>
      <description>&lt;p&gt;The &lt;a href="http://blog.labnotes.org/2006/09/04/assert_select-cheat-sheet/"&gt;assert_select&lt;/a&gt; method for testing views was added in &lt;a href="http://weblog.rubyonrails.org/2006/11/26/1-2-new-in-actionpack"&gt;Rails 1.2&lt;/a&gt;, so the first thing to check if you&amp;#8217;re getting the error below is that you&amp;#8217;ve upgraded to 1.2&lt;/p&gt;

&lt;pre&gt;
&gt;  2) Error:
&gt;test_expire_old_ads(AdExpirationTest):
&gt;NoMethodError: undefined method `assert_select' for #&lt;ActionController::Integration::Session:0x378ae98&gt;
&gt; c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/test_process.rb:432:in `method_missing'

&lt;/pre&gt;

&lt;p&gt;Now I upgraded to 1.2 and still kept getting the above error.  The problem was that my application was set to use Rails 1.1.6 in the config/environment.rb file:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="comment"&gt;# Specifies gem version of Rails to use when vendor/rails is not present&lt;/span&gt;
&lt;span class="constant"&gt;RAILS_GEM_VERSION&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;1.1.6&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;So the solution is to comment out that line, or alternatively ,set it to the latest version.  Also make sure you&amp;#8217;re not frozen to a specific Rails version in the vendor directory.&lt;/p&gt;</description>
      <pubDate>Mon, 19 Feb 2007 18:23:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:6ddf5409-4a21-4502-a1d6-b9dc8733aedc</guid>
      <author>Mike Blake</author>
      <link>http://martinicity.net/articles/2007/02/19/undefined-method-assert_select</link>
      <category>Create</category>
      <category>rails</category>
      <category>testing</category>
      <category>assert_select</category>
      <category>NoMethodError</category>
    </item>
    <item>
      <title>The Unselfish Act of Writing Tests</title>
      <description>&lt;p&gt;&lt;p&gt;&lt;/p&gt;

&lt;h4&gt;ORUG&lt;/h4&gt;

&lt;p&gt;At this months &lt;a href="http://www.orug.org"&gt;Orlando Ruby User&amp;#8217;s Group&lt;/a&gt; meeting, I did my &lt;a href="http://www.apptrain.net/testing/img0.html"&gt;Testing  on Rails&lt;/a&gt; presentation. In it I touched on just some of the benefits of having an automated suite of Unit, Functional, and Integration tests.
&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src="http://www.apptrain.net/testing/img4.jpg" alt="Benefits of Testing"/&gt;&lt;/p&gt;

&lt;p&gt;&lt;p&gt;
Later I thought of another major benefit. Tests help other people on the project, in addition to the author of the test.&lt;/p&gt;

&lt;h4&gt;Good Habits are Contagious&lt;/h4&gt;

&lt;p&gt;Recently I had the opportunity to work on a project with &lt;a href="http://blog.harrisreynolds.net/"&gt;Harris Reynolds&lt;/a&gt;.  Harris did something very important that sadly, you don&amp;#8217;t see on every Rails Project.  He wrote a unit test.  Lot&amp;#8217;s of us wrote tests , but this particular test stood out for two reasons.  The first was when it was written.&lt;/p&gt;

&lt;h4&gt;Writing Tests First&lt;/h4&gt;

&lt;p&gt;Harris had found a bug in a model object that I had created. To notify me, he checked in an assertion that failed, then emailed me. This saved me time searching thought and remembering code I had written.  I simply typed &lt;code&gt;rake test:recent&lt;/code&gt;   which runs all recently changed tests in a Rails application . The error took me right to the problem, and I immediately fixed the bug.&lt;/p&gt;

&lt;h4&gt;Testing a Deployment&lt;/h4&gt;

&lt;p&gt;The second reason I remember this test happened at least a month later. The application was being deployed to a new machine, and the test failed.  The particular model object being tested pointed to a different database that the rest of the application,  and it turned out that that database hadn&amp;#8217;t been installed correctly on the new machine.  Harris&amp;#8217;s test told the problem straight away, and saved time once again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unit Testing: the gift that keeps on giving.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Thanks Harris!&lt;/p&gt;</description>
      <pubDate>Wed, 14 Feb 2007 21:07:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:d3a23de4-6d31-4890-aaf1-7e6e04e61f32</guid>
      <author>Mike Blake</author>
      <link>http://martinicity.net/articles/2007/02/14/the-unselfish-act-of-writing-tests</link>
      <category>Create</category>
      <category>rails</category>
      <category>ruby</category>
      <category>unit tests</category>
      <category>ORUG</category>
    </item>
    <item>
      <title>Rails SafetyNet</title>
      <description>&lt;h2&gt;&lt;b&gt;Curent Mood:&lt;/b&gt; Bored with Deleting the Production Database&lt;/h2&gt;

&lt;p&gt;&lt;p&gt;&lt;/p&gt;

&lt;p&gt;I thought I was the only clown working on Rails projects and ignoring the &lt;a href="http://dev.rubyonrails.org/svn/rails/applications/plugins/config/database.example.yml"&gt;warning in config/database.yml&lt;/a&gt; and using rake to wipe out  perfectly good databases.  But I&amp;#8217;ve seen it happen to others now, and enough&amp;#8217;s enough.  So I created the &lt;h3&gt;SafetyNet Plugin&lt;/h3&gt;.&lt;/p&gt;

&lt;p&gt;You can install Safety Net in your app, by running&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
ruby script/plugin install svn://rubyforge.org/var/svn/apptrain/trunk/vendor/plugins/safety_net
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That&amp;#8217;s it. Now, If the &lt;b&gt;test&lt;/b&gt; database points to the same database as &lt;b&gt;development&lt;/b&gt; or &lt;b&gt;production&lt;/b&gt; running rake will display the following message:&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/safety_net.png" alt="safety net"/&gt;&lt;/p&gt;

&lt;pre&gt;
rake aborted! 



The name of your test database matches production or development.
&lt;/pre&gt;

&lt;h3&gt;How it Works&lt;/h3&gt;

&lt;p&gt;&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Purging the poor innocent database is prevented in two ways.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;By adding a prerequisite check to the rake script that normaly performs this task.&lt;/li&gt;
&lt;li&gt;By modifying the fixtures method on ActiveRecord to avoid the same fate when running individual tests with the ruby command. &lt;/li&gt;
&lt;/ol&gt;</description>
      <pubDate>Wed, 07 Feb 2007 21:14:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:7d6f994d-0845-41c7-a8ea-09a9157c94db</guid>
      <author>Mike Blake</author>
      <link>http://martinicity.net/articles/2007/02/07/safety-net</link>
      <category>Create</category>
      <category>safetynet</category>
      <category>safetynet</category>
      <category>apptrain</category>
      <category>rails</category>
      <category>plugin</category>
      <category>rake</category>
      <category>rails test database</category>
    </item>
    <item>
      <title>Keeping your Rails Codebase Clean with SVN Externals</title>
      <description>&lt;p&gt;As you develop a nice well organized Rails application, you&amp;#8217;re sure to utilize some of the great open source code already written by Rails developers.&lt;/p&gt;

&lt;p&gt;A common practice is to install a plugin or some other code into your application, then add that code to subversion. Some problems with this are that a checkout of your app now takes longer, and if the plugin improves, you are using old code in your application. A neater solution is to access third party code using &lt;strong&gt;SVN Externals.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using &lt;a href="http://tortoisesvn.tigris.org"&gt;Tortoise SVN&lt;/a&gt;, right click inside the vendor directory of your app, then choose &amp;#8216;properties&amp;#8217; from the menu.&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/svn_properties.gif" alt="svn properties"/&gt;&lt;/p&gt;

&lt;p&gt;Click the &amp;#8216;Subversion&amp;#8217; Tab with the little turtle. Then choose &lt;strong&gt;svn:externals&lt;/strong&gt; from the dropdown in the middle of the screen.&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/externals.gif" alt="svn:externals"/&gt;&lt;/p&gt;

&lt;p&gt;Now in the text area, enter the plugin you want to include.&lt;br/&gt;
&lt;code&gt;acts_as_authenticated&amp;nbsp;http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The format here is important, the first word the entry, before the first space will be the &lt;strong&gt;directory name&lt;/strong&gt; where the code will live.  After the first space is the &lt;strong&gt;url for the repository&lt;/strong&gt;. Click &amp;#8216;OK to save the external.  Then go up one directory and do a checkout of the &amp;#8216;vendor&amp;#8217; directory.&lt;/p&gt;

&lt;p&gt;Now:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If the plugin code changes, you&amp;#8217;ll receive the new code whenever you do an Update.&lt;/li&gt;
&lt;li&gt;Additional coders who check out the repository have the option to &amp;#8216;Omit externals&amp;#8217; if they don&amp;#8217;t need the portion of the code you&amp;#8217;ve included.&lt;/li&gt;
&lt;li&gt;There&amp;#8217;s a clear distinction in your repository between the code you&amp;#8217;re maintaining, and third party code.&lt;/li&gt;
&lt;/ol&gt;</description>
      <pubDate>Wed, 31 Jan 2007 16:25:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:dee6f8d3-128c-49df-abbe-ffc8ff243570</guid>
      <author>Mike Blake</author>
      <link>http://martinicity.net/articles/2007/01/31/keeping-your-rails-codebase-clean-with-svn-externals</link>
      <category>Create</category>
      <category>rails</category>
      <category>svn</category>
      <category>externals</category>
      <category>tortoise</category>
      <category>subversion</category>
    </item>
    <item>
      <title>New Rails Site: FanNation</title>
      <description>&lt;p&gt;The folks at &lt;a href="http://www.fannation.com"&gt;FanNation&lt;/a&gt; have done something that no one else in the sports world has done. 
&lt;span style="float:right;"&gt;
&lt;map id ="favorite_team_map" name="favorite_team_map"&gt;&lt;area shape ="rect" coords ="0,0,160,80" href="http://www.fannation.com" target ="_blank" alt="FanNation: The Republic of Sport" title="FanNation: The Republic of Sport" /&gt;&lt;area shape ="rect" coords ="10,82,150,102" href ="http://www.fannation.com/users/view_user_profile/530" target ="_blank" alt="mblake" title="mblake" /&gt;&lt;area shape ="rect" coords ="10,102,150,260" href ="http://www.fannation.com/player_trackers/team_overview/530" target ="_blank" alt="mblake's Favorite Teams" title="mblake's Favorite Teams" /&gt;&lt;area shape ="rect" coords ="0,265,160,300" href="http://www.fannation.com/remote/favorite_teams" target ="_blank" alt="Get your own Favorite Teams Widget!" title="Get your own Favorite Teams Widget!" /&gt;&lt;/map&gt;&lt;image src="http://www.fannation.com/remote/favorite_teams_image/530" alt="mblake's Favorites Teams" usemap="#favorite_team_map" border="0" /&gt;
&lt;/span&gt;
They&amp;#8217;ve created a &lt;a href="http://www.fannation.com"&gt;comprehensive site&lt;/a&gt; for sports fans to gather and share information about their favorite teams and players (fantasy too) , and it&amp;#8217;s all free.&lt;/p&gt;

&lt;p&gt;I spent some time with the &lt;a href="http://www.fannation.com/fannation/about"&gt;developers at FanNation&lt;/a&gt; working on the map on the home page.  They are a sharp bunch, and I&amp;#8217;m constantly amazed at the features they are adding each time I visit.  Fannation is now one of the biggest websites around developed on &lt;a href="http://www.rubyonrails.org/"&gt;Ruby on Rails&lt;/a&gt;.  Tag clouds, in place edits, Dynamic news updates using AJAX calls, personalized blogging.  This site is a tremendous example of practical usage of some of the latest technologies.  And it&amp;#8217;s loads of fun.&lt;/p&gt;

&lt;p&gt;There&amp;#8217;s tons of other functionality I haven&amp;#8217;t explored yet, but definitely keep an eye on FanNation!&lt;/p&gt;</description>
      <pubDate>Thu, 21 Sep 2006 17:25:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:a9b2f624-31cf-4d7a-b807-636c42cdc9c0</guid>
      <author>Mike Blake</author>
      <link>http://martinicity.net/articles/2006/09/21/new-rails-site-fannation</link>
      <category>Create</category>
      <category>fannation</category>
      <category>ruby</category>
      <category>rails</category>
    </item>
    <item>
      <title>Attend a Hackfest!</title>
      <description>&lt;p&gt;If you&amp;#8217;re a programmer like me you&amp;#8217;re a little intimidated by the &lt;a href="http://www.flickr.com/photos/45241414@N00/sets/72157594276834801/"&gt;Hackfest&lt;/a&gt;.  That is , you&amp;#8217;ve had several programming gigs over the years, attended a few more day &lt;a href="http://www.pluckthepetal.com/blackdaisies/2004/02/long_meetings/"&gt;long meetings&lt;/a&gt; than you&amp;#8217;d have liked, and fear that you&amp;#8217;ll be embarrassed by your perceived lack of skill compared to the young &lt;a href="http://www.rubyonrails.org/core"&gt;whiz kids&lt;/a&gt; with a burning passion for creating software.&lt;/p&gt;

&lt;p&gt;We&amp;#8217;ll let me assure you, the spirit of the hackfest is one of &lt;a href="http://redhanded.hobix.com/cult/everyoneIsHereInTheFuture2.html"&gt;learning and cooperation&lt;/a&gt; and not at all that of oneupmanship or competition.  At least not at the &lt;a href="http://www.orug.org"&gt;ORUG&lt;/a&gt; .&lt;/p&gt;

&lt;p&gt;I had a blast this past weekend and learned a lot from my piers, and left with the feeling that I had helped out as well.&lt;/p&gt;

&lt;p&gt;So my advice, fear not and attend a Hackfest!&lt;/p&gt;</description>
      <pubDate>Tue, 12 Sep 2006 14:30:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:cc7c8d73-4271-44eb-860e-545367b0a9d6</guid>
      <author>Mike Blake</author>
      <link>http://martinicity.net/articles/2006/09/12/attend-a-hackfest</link>
      <category>Create</category>
      <category>ruby</category>
      <category>rails</category>
      <category>hackfest</category>
      <category>ORUG</category>
    </item>
  </channel>
</rss>
