Martinicity: Rails SafetyNetMike Blaketag:martinicity.net,2005:TypoTypo2007-02-16T03:30:13+00:00Mike Blakeurn:uuid:7d6f994d-0845-41c7-a8ea-09a9157c94db2007-02-07T21:14:00+00:002007-02-16T03:30:13+00:00Rails SafetyNet<h2><b>Curent Mood:</b> Bored with Deleting the Production Database</h2>
<p><p></p>
<p>I thought I was the only clown working on Rails projects and ignoring the <a href="http://dev.rubyonrails.org/svn/rails/applications/plugins/config/database.example.yml">warning in config/database.yml</a> and using rake to wipe out perfectly good databases. But I’ve seen it happen to others now, and enough’s enough. So I created the <h3>SafetyNet Plugin</h3>.</p>
<p>You can install Safety Net in your app, by running</p>
<p><code>
ruby script/plugin install svn://rubyforge.org/var/svn/apptrain/trunk/vendor/plugins/safety_net
</code></p>
<p>That’s it. Now, If the <b>test</b> database points to the same database as <b>development</b> or <b>production</b> running rake will display the following message:</p>
<p><img src="/images/safety_net.png" alt="safety net"/></p>
<pre>
rake aborted!
The name of your test database matches production or development.
</pre>
<h3>How it Works</h3>
<p><p></p>
<p>Purging the poor innocent database is prevented in two ways.</p>
<ol>
<li>By adding a prerequisite check to the rake script that normaly performs this task.</li>
<li>By modifying the fixtures method on ActiveRecord to avoid the same fate when running individual tests with the ruby command. </li>
</ol>Peterurn:uuid:e9041211-1b84-4a48-95c5-7541b23db71c2007-02-14T21:33:14+00:002007-02-14T21:33:14+00:00Comment on Rails SafetyNet by Peter<p>Whoa! Great stuff. This is going into my project right now!</p>