<?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</title>
	<atom:link href="http://www.infused.org/category/ruby/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>DBF 1.0.9 update</title>
		<link>http://www.infused.org/2009/01/15/dbf-109-update/</link>
		<comments>http://www.infused.org/2009/01/15/dbf-109-update/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 19:32:44 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[DBF]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.infused.org/?p=483</guid>
		<description><![CDATA[DBF is a small fast Ruby library for reading dBase, xBase, Clipper and FoxPro database files
Changes in version 1.0.9:

Fix incorrect integer column values (only affecting some dbf files)
Add CSV export

]]></description>
			<content:encoded><![CDATA[<p><a href="http://github.com/infused/dbf/tree/masterg">DBF</a> is a small fast Ruby library for reading dBase, xBase, Clipper and FoxPro database files</p>
<p>Changes in version 1.0.9:</p>
<ul>
<li>Fix incorrect integer column values (only affecting some dbf files)</li>
<li>Add CSV export</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.infused.org/2009/01/15/dbf-109-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>DBF 1.0.6 update</title>
		<link>http://www.infused.org/2007/11/27/dbf-106-update/</link>
		<comments>http://www.infused.org/2007/11/27/dbf-106-update/#comments</comments>
		<pubDate>Wed, 28 Nov 2007 05:43:13 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[DBF]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.infused.org/2007/11/27/dbf-106-update/</guid>
		<description><![CDATA[DBF is a small fast library for reading dBase, xBase, Clipper and FoxPro database files. It is written completely in Ruby and has no external dependencies.
Changes in version 1.0.5:

Strip non-ascii characters from column names

]]></description>
			<content:encoded><![CDATA[<p><a href="http://dbf.rubyforge.org">DBF</a> is a small fast library for reading dBase, xBase, Clipper and FoxPro database files. It is written completely in Ruby and has no external dependencies.</p>
<p>Changes in version 1.0.5:</p>
<ul>
<li>Strip non-ascii characters from column names</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.infused.org/2007/11/27/dbf-106-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DBF 1.0.2 Update</title>
		<link>http://www.infused.org/2007/08/15/dbf-102-update/</link>
		<comments>http://www.infused.org/2007/08/15/dbf-102-update/#comments</comments>
		<pubDate>Wed, 15 Aug 2007 21:50:50 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[DBF]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.infused.org/2007/08/15/dbf-102-update/</guid>
		<description><![CDATA[DBF is a small fast library for reading dBase, xBase, Clipper and FoxPro database files. It is written completely in Ruby and has no external dependencies.
Changes in version 1.0.2:

Fixes a bug when reading Visual Foxpro memo files.

]]></description>
			<content:encoded><![CDATA[<p><a href="http://dbf.rubyforge.org">DBF</a> is a small fast library for reading dBase, xBase, Clipper and FoxPro database files. It is written completely in Ruby and has no external dependencies.</p>
<p>Changes in version 1.0.2:</p>
<ul>
<li>Fixes a bug when reading Visual Foxpro memo files.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.infused.org/2007/08/15/dbf-102-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>DBF 0.5.0 Update</title>
		<link>http://www.infused.org/2007/05/26/dbf-050-update/</link>
		<comments>http://www.infused.org/2007/05/26/dbf-050-update/#comments</comments>
		<pubDate>Sat, 26 May 2007 09:11:40 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[DBF]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.infused.org/2007/05/26/dbf-050-update/</guid>
		<description><![CDATA[A lot of work has gone into this release of the DBF gem.  The basic reader code is stable now. I&#8217;m in the process of moving the test suite from Test::Unit to Rspec. When I&#8217;m done with that I&#8217;ll add a couple of additional features, polish the documentation and christen it 1.0.0.

New find method
Full [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of work has gone into this release of the <a href="http://dbf.rubyforge.org">DBF gem</a>.  The basic reader code is stable now. I&#8217;m in the process of moving the test suite from Test::Unit to Rspec. When I&#8217;m done with that I&#8217;ll add a couple of additional features, polish the documentation and christen it 1.0.0.</p>
<ul>
<li>New find method</li>
<li>Full compatibility with the two flavors of memo file</li>
<li>Two modes of operation:
<ul>
<li>In memory (default): All records are loaded into memory on the first<br />
    request. Records are retrieved from memory for all subsequent requests.</li>
<li>File I/O: All records are retrieved from disk on every request</li>
</ul>
</li>
<li>Improved <a href="http://dbf.rubyforge.org/dbf">documentation</a> and more usage examples</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.infused.org/2007/05/26/dbf-050-update/feed/</wfw:commentRss>
		<slash:comments>1</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>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>Ruby DBF 0.4.0</title>
		<link>http://www.infused.org/2006/10/07/dbf-040/</link>
		<comments>http://www.infused.org/2006/10/07/dbf-040/#comments</comments>
		<pubDate>Sat, 07 Oct 2006 19:29:47 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.infused.org/2006/10/07/dbf-040/</guid>
		<description><![CDATA[New in dbf-0.4.0:

Support for dBase III style memo files
Documentation in doc/readme.txt
Fixed that field lengths were being read as signed integers, when they be should be unsigned
Fixed skipping over deleted records

Thank you to everybody that submitted patches and test files.  Keep &#8216;em coming.
]]></description>
			<content:encoded><![CDATA[<p>New in <a href="http://rubyforge.org/projects/dbf/">dbf</a>-0.4.0:</p>
<ul>
<li>Support for dBase III style memo files</li>
<li>Documentation in doc/readme.txt</li>
<li>Fixed that field lengths were being read as signed integers, when they be should be unsigned</li>
<li>Fixed skipping over deleted records</li>
</ul>
<p>Thank you to everybody that submitted patches and test files.  Keep &#8216;em coming.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.infused.org/2006/10/07/dbf-040/feed/</wfw:commentRss>
		<slash:comments>3</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>
	</channel>
</rss>
