<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>infused.org &#187; Ruby on Rails</title>
	<atom:link href="http://www.infused.org/category/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.infused.org</link>
	<description></description>
	<lastBuildDate>Tue, 05 Jan 2010 00:33:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Blame Game</title>
		<link>http://www.infused.org/2009/01/05/the-blame-game/</link>
		<comments>http://www.infused.org/2009/01/05/the-blame-game/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 00:20:07 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.infused.org/?p=440</guid>
		<description><![CDATA[In just about every Rails project I&#8217;ve worked on over the last several years we&#8217;ve needed track the user who creates and updates database records.  The most popular solution seems to be DeLynn Berry&#8217;s userstamp plugin and, until recently, that&#8217;s what we&#8217;ve always chosen to use too.  But after fighting incompatibility with newer [...]]]></description>
			<content:encoded><![CDATA[<p>In just about every Rails project I&#8217;ve worked on over the last several years we&#8217;ve needed track the user who creates and updates database records.  The most popular solution seems to be DeLynn Berry&#8217;s userstamp plugin and, until recently, that&#8217;s what we&#8217;ve always chosen to use too.  But after fighting incompatibility with newer versions of Rails I decided to write my own plugin.  Enter <a href="http://github.com/infused/blame/tree/master">Blame</a>.</p>
<p>Blame automatically userstamps create and update operations if the table has columns named created_by and/or updated_by.</p>
<p><b>Installation:</b></p>
<pre><code>ruby script/plugin install git://github.com/infused/blame.git</code></pre>
<p>Blame assumes that you are using <a href="http://github.com/technoweenie/restful-authentication/tree/master">restful-authentication</a> and expects User.current_user to return the current user. You can override this behavior by overriding the default userstamp_object method in ActiveRecord::Base or in any of your models. For example, maybe you just want to find the current user bases on the a session variable:</p>
<pre><code># In environment.rb
class ActiveRecord::Base
  def userstamp_object
    User.find(session[:user_id])
  end
end
</code></pre>
<p>Maybe you don’t like the default column names of created_by/updated_by. You can customize the column names globally or for individual models:</p>
<pre><code># Globally in environment.rb
ActiveRecord::Base.created_userstamp_column = :creator_id

# In a model definition
class Subscription
  self.created_userstamp_column = :creator_id
  self.updated_userstamp_column = :updater_id
end
</code></pre>
<p>Automatic userstamping can be turned off by setting record_userstamps:</p>
<pre><code># Globally in environment.rb
ActiveRecord::Base.record_userstamps = false

# In a model definition
class Subscription
  self.record_userstamps = false
end

</code></pre>
<p>Blame also adds a migration helper which will add the created_by and updated_by columns (or your custom column names) to your table:</p>
<pre><code>create_table :widgets do |t|
  t.string :name
  t.timestamps
  t.userstamps
end
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.infused.org/2009/01/05/the-blame-game/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Returning supported HTTP methods with &#8216;verify&#8217;</title>
		<link>http://www.infused.org/2007/02/12/376/</link>
		<comments>http://www.infused.org/2007/02/12/376/#comments</comments>
		<pubDate>Tue, 13 Feb 2007 02:36:40 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.infused.org/2007/02/12/376/</guid>
		<description><![CDATA[When using Rails&#8217; verify method to protect your ActionController actions, you should return a list of the allowed HTTP methods in the response headers.
Let&#8217;s say you have an action called update that you want to protect from anything but a POST.  I like to do it like this:
verify :method => :post, :only => :update, [...]]]></description>
			<content:encoded><![CDATA[<p>When using Rails&#8217; <a href="http://api.rubyonrails.com/classes/ActionController/Verification/ClassMethods.html#M000175">verify</a> method to protect your ActionController actions, you should return a list of the allowed HTTP methods in the response headers.</p>
<p>Let&#8217;s say you have an action called update that you want to protect from anything but a POST.  I like to do it like this:</p>
<div class="code">verify :method => :post, :only => :update, :render => {:text => &#8216;405 HTTP POST required&#8217;, :status => 405}, :add_headers => {&#8216;Allow&#8217; => &#8216;POST&#8217;}
</div>
<p>Now if someone tries to hit the update action with anything other than a POST, an error message will be displayed and the response headers will contain (among other things):</p>
<div class="code">{&#8220;Status&#8221;=>&#8221;405 Method Not Allowed&#8221;, &#8220;Allow&#8221;=>&#8221;POST&#8221;}</div>
<p>In my opinion, this is a better way to go than redirecting to another action because the use of an improper HTTP method is most likely the result of either programmer error or malicious intent.  By redirecting to another page, you are making it much easier to for somebody to take your site down with a denial of service attack and if it&#8217;s a programming error, you&#8217;ll locate the problem faster.</p>
<p>You should also make sure that you have a functional test for this behavior:</p>
<pre>
<div class="code">def test_invalid_update_methods
  [:get, :put, :delete].each do |http_method|
    send http_method, :update
    assert_response 405
    assert_equal 'POST', @response.headers['Allow']
    assert_equal '405 HTTP POST required', @response.body
  end
end
</div>
</pre>
<h3>Additional Resources</h3>
<ul>
<li><a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">HTTP 1.1: Status Code Definitions</a></li>
<li><a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html">HTTP 1.1: Header Field Definitions</a></li>
<li><a href="http://api.rubyonrails.com/classes/ActionController/Verification/ClassMethods.html#M000175">Rails API Documentation: Verification</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.infused.org/2007/02/12/376/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Going Nowhere for RailsConf 2007</title>
		<link>http://www.infused.org/2007/02/02/going-nowhere-for-railsconf-2007/</link>
		<comments>http://www.infused.org/2007/02/02/going-nowhere-for-railsconf-2007/#comments</comments>
		<pubDate>Fri, 02 Feb 2007 22:49:29 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.infused.org/2007/02/02/going-nowhere-for-railsconf-2007/</guid>
		<description><![CDATA[RailsConf will be held right here in Portland this year, so no travelling for me this time around.  The conference is being held at the Oregon Convention Center (the same place OSCON is held every year), so it&#8217;s a huge improvement over the shitty hotel in Chicago where it was held last year.
Registration just [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://conferences.oreillynet.com/rails/">RailsConf</a> will be held right here in Portland this year, so no travelling for me this time around.  The conference is being held at the Oregon Convention Center (the same place OSCON is held every year), so it&#8217;s a huge improvement over the shitty hotel in Chicago where it was held last year.</p>
<p>Registration just opened a couple of hours ago.  This year the registration fee is higher and the venue is a lot larger so it probably won&#8217;t sell out as quickly as last year.  But, if you want to go, I would sign up soon.  I already did.</p>
<p>Updates:</p>
<ul>
<li>7 hours later: I&#8217;m glad I bought mine early, because <a href="http://weblog.rubyonrails.com/2007/2/2/one-third-of-railsconf-07-seats-gone">they might sell out faster than last year</a>.</li>
<li>3 days later: <a href="http://www.37signals.com/svn/posts/250-railsconf-07-sells-faster-than-any-other-oreilly-conference">RailsConf &#8216;07 sells faster than any other O&#8217;Reilly conference</a></li>
<li>9 days later: <a href="http://weblog.rubyonrails.com/2007/2/11/railsconf-sells-more-than-2-3s-railsconf-eu-rfp-open">close to 75%</a> of the tickets have now been sold.
</li>
<li>22 days later: <a href="http://weblog.rubyonrails.com/2007/2/24/railsconf-07-sold-out">Sold out</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.infused.org/2007/02/02/going-nowhere-for-railsconf-2007/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Deploying Rails with Pound in front of Apache and Mongrel on Redhat ES4 with Ensim &#8211; Part 1</title>
		<link>http://www.infused.org/2006/12/14/deploying-rails-with-pound-in-front-of-apache-and-mongrel-on-redhat-es4-with-ensim-part-1/</link>
		<comments>http://www.infused.org/2006/12/14/deploying-rails-with-pound-in-front-of-apache-and-mongrel-on-redhat-es4-with-ensim-part-1/#comments</comments>
		<pubDate>Thu, 14 Dec 2006 22:45:49 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.infused.org/2006/12/14/deploying-rails-with-pound-in-front-of-apache-and-mongrel-on-redhat-es4-with-ensim-part-1/</guid>
		<description><![CDATA[I have my own dedicated server running Ensim on which I run quite a few sites.  Most of these are either static HTML or PHP sites, but I also host a couple of Rails apps on the same box using Lighttpd.  That has turned out not to be the most reliable setup.  [...]]]></description>
			<content:encoded><![CDATA[<p>I have my own dedicated server running <a href="http://www.ensim.com">Ensim</a> on which I run quite a few sites.  Most of these are either static HTML or PHP sites, but I also host a couple of Rails apps on the same box using Lighttpd.  That has turned out not to be the most reliable setup.  After a year of killing hung dispatchers I decided to give mongrel_cluster and Pound a try. This is how I did it.  </p>
<p>Note that these instructions are specific to Redhat ES4 with Ensim, though most of this stuff should work on other flavors of *nix with some slight modifications.  </p>
<h3>Prerequisites</h3>
<p>The only prerequisite for Pound that I am aware of is <em>pcre</em>.  You probably already have it installed, but if you don&#8217;t, install in via up2date, yum, or whatever.</p>
<h3>Installing Pound</h3>
<p>Download, configure and install <a href="http://www.apsis.ch/pound/">Pound</a>.  There are stable and experimental versions to choose from.  I&#8217;m using the latest experimental release:</p>
<div class="code">
wget http://www.apsis.ch/pound/Pound-2.1.8.tgz<br />
tar vxzf Pound-2.1.8.tgz<br />
cd Pound-2.1.8<br />
./configure<br />
make<br />
make install
</div>
<h3>Test Configuration</h3>
<p>I don&#8217;t like the default location for Pound&#8217;s configuration file, so I&#8217;ve created mine file here: <em>/etc/pound/pound.cfg</em></p>
<p>In order to make sure everything is working as expected, we&#8217;re going to start with a test configuration. Something simple.  Put this in your <em>/etc/pound/pound.cfg</em> file for now:</p>
<blockquote><pre>
LogLevel 0
Alive 30

ListenHTTP
  Address 0.0.0.0
  Port 81

  Service
    BackEnd
      Address YOUR SERVER'S EXTERNAL IP
      Port 80
    End
  End

End
</pre>
</blockquote>
<p>This configuration will proxy all inbound requests to port 81 over to Apache running on port 80.  Now try to start up pound:</p>
<div class="code">
pound -v -f /etc/pound/pound.cfg
</div>
<p>If it started properly, you&#8217;ll get no output.  You should get an error if it couldn&#8217;t start up.  Use
<div class="code">ps -ef | grep pound</div>
<p> to see if it&#8217;s running.  If so, try to browse to one of the sites on your server using port 81.  For example: http://www.infused.org:81.  If it works we&#8217;re in business, so we&#8217;ll create a pound start-up script and configure it to start up on boot.</p>
<h3>Setup Pound daemon</h3>
<p>Create a <em>/etc/init.d/pound</em> file with the following contents:</p>
<blockquote><pre>
#!/bin/sh
. /etc/rc.d/init.d/functions

# To add to services:
# chkconfig --add pound

# Enable automatic start on boot
# chkconfig pound on

### BEGIN INIT INFO
# Provides:       pound
# Required-Start: $network $syslog
# Required-Stop:
# Default-Start:  3 5
# Default-Stop:
# Description:    Starts pound reverse proxy
### END INIT INFO

if [ -z "$POUND_CONF_PATH" ]; then
        POUND_CONF_PATH="/etc/pound/pound.conf"
fi

prog="pound"
pound="/usr/local/sbin/pound"
RETVAL=0

start() {
        echo -n $"Starting $prog: "
        daemon $pound -f $POUND_CONF_PATH
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] &#038;&#038; touch /var/lock/subsys/$prog
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog: "
        killproc $pound
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] &#038;&#038; rm -f /var/lock/subsys/$prog
        return $RETVAL
}

reload() {
        echo -n $"Reloading $prog: "
        killproc $pound -HUP
        RETVAL=$?
        echo
        return $RETVAL
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                stop
                start
                ;;
        condrestart)
                if [ -f /var/lock/subsys/$prog ]; then
                        stop
                        start
                fi
                ;;
        reload)
                reload
                ;;
        status)
                status $pound
                RETVAL=$?
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"
                RETVAL=1
esac

exit $RETVAL
</pre>
</blockquote>
<p>Now you can configure Pound as a service and set it to start on boot:</p>
<div class="code">
chmod +x /etc/init.d/pound<br />
chkconfig &#8211;add pound<br />
chkconfig pound on
</div>
<p>Use the ps command again to find and then kill the pound instance you started earlier.  You will probably see to instances running.  Kill the first one, and the other will die with it.  Once the test instance is dead, you can start, stop, and restart Pound like any other service.  To start it up as a service:</p>
<div class="code">
service pound start
</div>
<h3>The Real Deal</h3>
<p>Test it by browsing to a site on port 81 again.  If everything looks good, it&#8217;s time to do this thing for real.  Edit <em>/etc/pound/pound.cfg</em> and swap the ports between the proxy and the backend server.  The file should now look like this:</p>
<blockquote><pre>
LogLevel 0
Alive 30

ListenHTTP
  Address 0.0.0.0
  Port 80

  Service
    BackEnd
      Address 67.15.198.2
      Port 81
    End
  End

End
</pre>
</blockquote>
<p>Log into your Ensim control panel as the Appliance Administrator and click on the Web Server link.  Change port 80 to 81 and click Update Configuration.</p>
<p>With the appliance updated, we now need to restart Apache and Pound to pick up their new configurations:</p>
<div class="code">
service pound stop<br />
service httpd restart<br />
service pound start
</div>
<p>All your sites should now be accessible on port 80.  Try them out.  If you don&#8217;t see any problems, there is one important step left to do.  </p>
<h3>Fix Apache Logging</h3>
<p>Right now, all the Apache logs will show you server&#8217;s IP address as the remote address.  To fix this, you need to swap out %h for \&#8221;%{X-Forwarded-for}i\&#8221; in any LogFormat line in /etc/httpd/conf/httpd20_app.conf</p>
<p>You may have LogFormat lines in other files too, such as /etc/httpd/conf/httpd.conf.  Change those too.</p>
<p>My LogFormat directive now looks like this (on one line):</p>
<div class="code">LogFormat &#8220;%v:\&#8221;%{X-Forwarded-for}i\&#8221; %l %u %t \&#8221;%r\&#8221; %>s %b \&#8221;%{Referer}i\&#8221; \&#8221;%{User-Agent}i\&#8221;" ecombined</div>
<p>Restart Apache again and you&#8217;re done.</p>
<div class="code">
service httpd restart
</div>
<h3>Subversion</h3>
<p>If you are running Subversion under Apache, you&#8217;ll also need to tell Pound to allow the proper HTTP verbs.  Add the following line to /etc/pound/pound.cfg, right under ListenHTTP:</p>
<div class="code">
xHTTP 2
</div>
<p>By the way, this also tells Pound to allow the PUT and DELETE verbs, which you&#8217;ll need if you&#8217;re using the map.resources stuff in Rails.  </p>
<h3>Additional Resources</h3>
<ul>
<li><a href="http://www.apsis.ch/pound/">Official Pound site</a></li>
<li><a href="http://blog.tupleshop.com/2006/7/8/deploying-rails-with-pound-in-front-of-mongrel-lighttpd-and-apache">Deploying Rails with Pound in Front of Mongrel, Lighttpd, and Apache</a></li>
</ul>
<h3>Coming Up</h3>
<p>The stage is now set for Part 2, where I set up Pound to proxy to several Rails apps which are running under mongrel_cluster.  Stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.infused.org/2006/12/14/deploying-rails-with-pound-in-front-of-apache-and-mongrel-on-redhat-es4-with-ensim-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hear Me RoR</title>
		<link>http://www.infused.org/2006/11/03/hear-me-ror/</link>
		<comments>http://www.infused.org/2006/11/03/hear-me-ror/#comments</comments>
		<pubDate>Fri, 03 Nov 2006 19:30:41 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://www.infused.org/2006/11/03/hear-me-ror/</guid>
		<description><![CDATA[Three weeks ago I left the security of my job of the last 8 years to pursue a new career as a freelance consultant/programmer.  
I&#8217;ve been freelancing part-time for several years and it was always a nice supplement to my income, but I was afraid of going it alone.  What if I couldn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Three weeks ago I left the security of my job of the last 8 years to pursue a new career as a freelance consultant/programmer.  </p>
<p>I&#8217;ve been freelancing part-time for several years and it was always a nice supplement to my income, but I was afraid of going it alone.  What if I couldn&#8217;t make enough to support my family?  What if I&#8217;m not good enough?  What if I fail and have to go find a job?  What will people think of me then?</p>
<p>Earlier this year I came to the realization that there is no reason to fear failing.  Would it be the end of the world if I did fail?  Hardly. Would I be embarrassed?  Probably. But, embarrassed or not, I can always change gears or find another job.  I could even give up and just lay around watching TV all day while my wife supports me.</p>
<p>So, now I&#8217;m doing what I really love: Developing the best software that I&#8217;m able, using Ruby and Ruby on Rails.  I also plan to spend more time working on my own software and writing about Ruby and Ruby on Rails. I&#8217;m even considering doing some speaking on the subject.</p>
<p>Are you looking for an experienced Ruby or Ruby on Rails developer? Maybe you&#8217;re just looking for some mentoring or guidance on a project?  Send me an email at <a href="mailto:keithm@infused.org">keithm at infused.org</a>.  I&#8217;m always looking for exciting new projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.infused.org/2006/11/03/hear-me-ror/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>update_attributes_if_changed</title>
		<link>http://www.infused.org/2006/09/28/update_attributes_if_changed/</link>
		<comments>http://www.infused.org/2006/09/28/update_attributes_if_changed/#comments</comments>
		<pubDate>Thu, 28 Sep 2006 17:25:42 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.infused.org/2006/09/28/update_attributes_if_changed/</guid>
		<description><![CDATA[Update_attributes is not very smart; it will update a record whether or not the hash you pass it contains any changed values.  If you aren&#8217;t careful, you could end up with a ton of database writes for no reason.  Try my update_attributes_if_changed method instead:


module ActiveRecord
  class Base

    def update_attributes_if_changed(hash)
 [...]]]></description>
			<content:encoded><![CDATA[<p>Update_attributes is not very smart; it will update a record whether or not the hash you pass it contains any changed values.  If you aren&#8217;t careful, you could end up with a ton of database writes for no reason.  Try my <em>update_attributes_if_changed</em> method instead:</p>
<div class="code">
<pre>
module ActiveRecord
  class Base

    def update_attributes_if_changed(hash)
      update_attributes(hash) if needs_update?(hash)
    end

    def needs_update?(hash)
      hash.stringify_keys!
      !attributes.dup.delete_if{|k,v| !hash.key?(k) || hash[k] == v}.empty?
    end

    def write_attributes(hash)
      attributes.merge(hash.stringify_keys)
    end

  end
end
</pre>
</div>
<p>I&#8217;ve thrown in a method called <em>write_attributes</em> too.  It works just like <em>update_attributes</em>, but it doesn&#8217;t automatically save the record.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.infused.org/2006/09/28/update_attributes_if_changed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Formatting text_field</title>
		<link>http://www.infused.org/2006/09/26/formatting-text_field/</link>
		<comments>http://www.infused.org/2006/09/26/formatting-text_field/#comments</comments>
		<pubDate>Tue, 26 Sep 2006 23:43:14 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.infused.org/2006/09/26/formatting-text_field/</guid>
		<description><![CDATA[Yesterday, somebody asked me if it&#8217;s possible to format the contents of an input field using the text_field form helper.  
I don&#8217;t think its documented in the API docs, but you can specify the value to use by passing in a value parameter:

text_field :book, :title, :value => @book.title.upcase

]]></description>
			<content:encoded><![CDATA[<p>Yesterday, somebody asked me if it&#8217;s possible to format the contents of an input field using the text_field form helper.  </p>
<p>I don&#8217;t think its documented in the API docs, but you can specify the value to use by passing in a value parameter:</p>
<div class="code">
<pre>text_field :book, :title, :value => @book.title.upcase</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.infused.org/2006/09/26/formatting-text_field/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Test Injector Plugin for Rails</title>
		<link>http://www.infused.org/2006/07/28/test-injector-plugin-for-rails/</link>
		<comments>http://www.infused.org/2006/07/28/test-injector-plugin-for-rails/#comments</comments>
		<pubDate>Sat, 29 Jul 2006 00:56:54 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.infused.org/2006/07/28/test-injector-plugin-for-rails/</guid>
		<description><![CDATA[I&#8217;ve been working on a very large Rails projects at work and found myself spending a lot of time writing the same unit tests over and over again.  The application has a very complex database schema and has 159 ActiveRecord models so far.  With this many models, there are obviously a ton of [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a very large Rails projects at work and found myself spending a lot of time writing the same unit tests over and over again.  The application has a very complex database schema and has 159 ActiveRecord models so far.  With this many models, there are obviously a ton of associations.  I decided that I needed a way to automatically test every association that is defined in a model.  </p>
<p>The TestInjector plugin is the result.  I still have a lot of functionality that I want to add, but it works very well and it&#8217;s ready for others to use.</p>
<p>I posted the details on the Rails wiki:<br />
<a href="http://wiki.rubyonrails.org/rails/pages/TestInjector">http://wiki.rubyonrails.org/rails/pages/TestInjector</a></p>
<p>Or just install it using the plugin manager and take a look at the README file for more details:</p>
<div class="code">
<pre>script/plugin install http://www.infused.org/svn/plugins/test_injector</pre>
</div>
<p>or:</p>
<div class="code">
<pre>script/plugin discover
script/plugin install test_injector</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.infused.org/2006/07/28/test-injector-plugin-for-rails/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Sticky Scoped Access</title>
		<link>http://www.infused.org/2006/07/20/sticky-scoped-access/</link>
		<comments>http://www.infused.org/2006/07/20/sticky-scoped-access/#comments</comments>
		<pubDate>Thu, 20 Jul 2006 19:09:17 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.infused.org/2006/07/20/sticky-scoped-access/</guid>
		<description><![CDATA[Anybody else have this problem with Anna Chan&#8217;s ScopedAccess plugin?
Using a around_filter with ScopedAccess::Filter or the scoped_access helper works fine in normal usage, but when running rake test:functionals, the scope from previously run tests carries over into later tests.  In other words with_scope is being set but not removed.
Maybe this is because the controllers [...]]]></description>
			<content:encoded><![CDATA[<p>Anybody else have this problem with <a href="http://habtm.com/articles/2006/02/22/nested-with_scope">Anna Chan&#8217;s ScopedAccess</a> plugin?</p>
<p>Using a around_filter with ScopedAccess::Filter or the scoped_access helper works fine in normal usage, but when running rake test:functionals, the scope from previously run tests carries over into later tests.  In other words with_scope is being set but not removed.</p>
<p>Maybe this is because the controllers are not being torn down after the corresponding functional test is run?  I&#8217;m tired of peppering my functional test setup methods with Whatever.reset_scope.  Anybody have a quick fix for me?  I have other things to do, and I&#8217;d like to avoid looking deeper into this one&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.infused.org/2006/07/20/sticky-scoped-access/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Tossed Salad</title>
		<link>http://www.infused.org/2006/06/15/tossed-salad/</link>
		<comments>http://www.infused.org/2006/06/15/tossed-salad/#comments</comments>
		<pubDate>Thu, 15 Jun 2006 21:09:59 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.infused.org/?p=352</guid>
		<description><![CDATA[I&#8217;ve been keeping myself user busy the last few weeks and haven&#8217;t made the time to post anything.  

RailsConf 2006 is only 5 days away.  I&#8217;m flying.  While the ArgonExpress would be a good opportunity to hang out with the cool kids, I can&#8217;t stomach the thought of being stuck in on [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been keeping myself user busy the last few weeks and haven&#8217;t made the time to post anything.  </p>
<ul>
<li>RailsConf 2006 is only 5 days away.  I&#8217;m flying.  While the <a href="http://www.theargonexpress.com/">ArgonExpress</a> would be a good opportunity to hang out with the cool kids, I can&#8217;t stomach the thought of being stuck in on a train for several days.  I hope they make it to Chicago alive.</li>
<li>The server migration is almost complete.  Last night I installed lighttpd on the new box, setup Apache to proxy requests to the Rails sites running under lighttpd, and migrated all of the Subversion repositories.  There is only one site left to move.  Just waiting on the client.</li>
<li>I&#8217;ve written a lot of stuff in Rails over the last several weeks which may be useful to others.  I&#8217;ll try to package these up and post them before or during RailsConf:
<ul>
<li>Global unit tests:  Tests that are defined in one place that will run for any ActiveRecord model with the right attributes.  So far I have test_acts_as_versioned, test_optimisitic_locking, and test_fixtures_loaded_for_all_associations.  The last one is very handy.  It reflects on all associations and gives you a list of fixtures that need to be defined in each unit test.</li>
<li>Plugin: update_attributes_if_changed.  Only updates the attributes if anything has changed.  If you are using update_attributes on models with updated_at columns and acts_as_versioned you&#8217;ll want this.</li>
<li>ActiveRecord synchronizer:  One way synchronization with data transformations, conditions, defaults, etc.  Very handy for synchronizing with legacy databases. Complete with DSL.</li>
<li>Datadumper plugin:  Dump data in several format, but mosty used for dumping data into a format usable in migrations.  Especially nice for prepopulating domain tables using migrations.</li>
<li>Validation:  validates_association.  Not to be confused with validates_associated.  Validates_association validates that the associated object is of the correct class as specified in the association declaration.</li>
</ul>
</li>
<li>Surprisingly, I found out that I really like watching soccer.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.infused.org/2006/06/15/tossed-salad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
