<?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>cameronyule.com &#187; ruby</title>
	<atom:link href="http://cameronyule.com/tags/ruby/feed" rel="self" type="application/rss+xml" />
	<link>http://cameronyule.com</link>
	<description>Glasgow based new media developer Cameron Yule.</description>
	<lastBuildDate>Fri, 22 Jan 2010 12:53:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Mailbuild gem 1.1.1 release</title>
		<link>http://cameronyule.com/2008/11/mailbuild-gem-111-release</link>
		<comments>http://cameronyule.com/2008/11/mailbuild-gem-111-release#comments</comments>
		<pubDate>Fri, 07 Nov 2008 12:05:03 +0000</pubDate>
		<dc:creator>Cameron</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[mailbuild]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubygem]]></category>

		<guid isPermaLink="false">http://cameronyule.com/?p=331</guid>
		<description><![CDATA[I pushed an update to the Mailbuild gem this morning in response to a bug report from Michael Larocque, who found it wasn&#8217;t properly defaulting to the first List ID if none was specified explicitly. Full details can be found in the commit on the github mirror.]]></description>
			<content:encoded><![CDATA[<p>I pushed an update to the Mailbuild gem this morning in response to a bug report from <a href="http://prolumina.com">Michael Larocque</a>, who found it wasn&#8217;t properly defaulting to the first List ID if none was specified explicitly.</p>
<p>Full details can be found in <a href="http://github.com/cameronyule/mailbuild/commit/cd41013cce5b3a4f8717e9c6e4d0853a692d4ffe">the commit</a> on the github mirror.</p>
]]></content:encoded>
			<wfw:commentRss>http://cameronyule.com/2008/11/mailbuild-gem-111-release/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Polymorphs &#8216;is not a taggable model&#8217;</title>
		<link>http://cameronyule.com/2008/10/polymorphs-is-not-a-taggable-model</link>
		<comments>http://cameronyule.com/2008/10/polymorphs-is-not-a-taggable-model#comments</comments>
		<pubDate>Mon, 27 Oct 2008 11:17:44 +0000</pubDate>
		<dc:creator>Cameron</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[has_many_polymorphs]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://cameronyule.com/?p=311</guid>
		<description><![CDATA[I&#8217;ve been having an issue with Has Many Polymorphs tagging functionality where I was getting a "Model is not a taggable model" error while using the tagging methods. As I&#8217;m not alone in having this problem, here&#8217;s a quick fix. At the bottom of environment.rb; require 'tagging_extensions' require 'tag']]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been having an issue with <a href="http://github.com/fauna/has_many_polymorphs/tree/master">Has Many Polymorphs</a> tagging functionality where I was getting a <code>"Model is not a taggable model"</code> error while using the tagging methods. </p>
<p>As I&#8217;m <a href="https://rubyforge.org/forum/forum.php?thread_id=21365&#038;forum_id=16450">not</a> <a href="https://rubyforge.org/forum/forum.php?thread_id=28883&#038;forum_id=16450">alone</a> in having this problem, here&#8217;s a quick fix. </p>
<p>At the bottom of environment.rb;</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'tagging_extensions'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'tag'</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://cameronyule.com/2008/10/polymorphs-is-not-a-taggable-model/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Auditing models with user_stamp</title>
		<link>http://cameronyule.com/2008/10/auditing-models-with-user_stamp</link>
		<comments>http://cameronyule.com/2008/10/auditing-models-with-user_stamp#comments</comments>
		<pubDate>Fri, 24 Oct 2008 09:39:01 +0000</pubDate>
		<dc:creator>Cameron</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[audit]]></category>
		<category><![CDATA[models]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://cameronyule.com/?p=277</guid>
		<description><![CDATA[As part of a CMS I&#8217;m building I wanted the ability to audit user interaction with data, to prevent the situation where content is being created, deleted or edited with no record of who did what and when. John Nunemaker recently released his User Stamp plug-in which stamps records with the ID of the users that [...]]]></description>
			<content:encoded><![CDATA[<p>As part of a CMS I&#8217;m building I wanted the ability to audit user interaction with data, to prevent the situation where content is being created, deleted or edited with no record of who did what and when.</p>
<p>John Nunemaker recently released his <a href="http://railstips.org/2008/10/17/who-done-what-a-k-a-user-stamping">User Stamp</a> plug-in which stamps records with the ID of the users that created and last updated. The implementation is quite clever, as he&#8217;s managed to work around the usual hack of storing the current user ID in <code>Thread.current</code> to make it accessible to the model by using a Sweeper, as they have access to controllers (and hence the current_user method).</p>
<p>I&#8217;ve taken his code a bit further by creating a Log model which stores a polymorphic reference to the record affected, the event that occurred (e.g. &#8216;deleted&#8217; or &#8216;updated&#8217;), the current user ID and the time it happened.</p>
<p>The Log model;</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Log <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#CC00FF; font-weight:bold;"><span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span></span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Relationships</span>
  <span style="color:#5A0A0A; font-weight:bold;">belongs_to</span> <span style="color:#ff3333; font-weight:bold;">:user</span>
  <span style="color:#5A0A0A; font-weight:bold;">belongs_to</span> <span style="color:#ff3333; font-weight:bold;">:loggable</span>, <span style="color:#ff3333; font-weight:bold;">:polymorphic</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> :<span style="color:#0000FF; font-weight:bold;">true</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Validations</span>
  <span style="color:#5A0A0A; font-weight:bold;">validates_presence_of</span> <span style="color:#ff3333; font-weight:bold;">:loggable_type</span>
  <span style="color:#5A0A0A; font-weight:bold;">validates_presence_of</span> <span style="color:#ff3333; font-weight:bold;">:loggable_id</span>
  <span style="color:#5A0A0A; font-weight:bold;">validates_presence_of</span> <span style="color:#ff3333; font-weight:bold;">:action</span>
  <span style="color:#5A0A0A; font-weight:bold;">validates_presence_of</span> <span style="color:#ff3333; font-weight:bold;">:user</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>The migration;</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> CreateLogs <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#CC00FF; font-weight:bold;"><span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span></span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span>
    create_table <span style="color:#ff3333; font-weight:bold;">:logs</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span>
      t.<span style="color:#9900CC;">string</span> <span style="color:#ff3333; font-weight:bold;">:loggable_type</span>
      t.<span style="color:#9900CC;">integer</span> <span style="color:#ff3333; font-weight:bold;">:loggable_id</span>
      t.<span style="color:#9900CC;">string</span> <span style="color:#ff3333; font-weight:bold;">:action</span>
      t.<span style="color:#9900CC;">references</span> <span style="color:#ff3333; font-weight:bold;">:user</span>
      t.<span style="color:#9900CC;">timestamps</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    add_index <span style="color:#ff3333; font-weight:bold;">:logs</span>, <span style="color:#ff3333; font-weight:bold;">:loggable_id</span>
    add_index <span style="color:#ff3333; font-weight:bold;">:logs</span>, <span style="color:#ff3333; font-weight:bold;">:user_id</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span>
    drop_table <span style="color:#ff3333; font-weight:bold;">:logs</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Additional callback methods added to <code>UserStampSweeper</code>;</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#5A0A0A; font-weight:bold;">after_create</span><span style="color:#006600; font-weight:bold;">&#40;</span>record<span style="color:#006600; font-weight:bold;">&#41;</span>
    add_log<span style="color:#006600; font-weight:bold;">&#40;</span>record, <span style="color:#996600;">'created'</span><span style="color:#006600; font-weight:bold;">&#41;</span>    
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> after_update<span style="color:#006600; font-weight:bold;">&#40;</span>record<span style="color:#006600; font-weight:bold;">&#41;</span>
    add_log<span style="color:#006600; font-weight:bold;">&#40;</span>record, <span style="color:#996600;">'updated'</span><span style="color:#006600; font-weight:bold;">&#41;</span>    
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> after_destroy<span style="color:#006600; font-weight:bold;">&#40;</span>record<span style="color:#006600; font-weight:bold;">&#41;</span>
    add_log<span style="color:#006600; font-weight:bold;">&#40;</span>record, <span style="color:#996600;">'delete'</span><span style="color:#006600; font-weight:bold;">&#41;</span>    
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  private
  <span style="color:#9966CC; font-weight:bold;">def</span> add_log<span style="color:#006600; font-weight:bold;">&#40;</span>record, action<span style="color:#006600; font-weight:bold;">&#41;</span>
    Log.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span>
      <span style="color:#ff3333; font-weight:bold;">:loggable_type</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> record.<span style="color:#9966CC; font-weight:bold;">class</span>.<span style="color:#5A0A0A; font-weight:bold;">to_s</span>, 
      <span style="color:#ff3333; font-weight:bold;">:loggable_id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> record.<span style="color:#9900CC;">id</span>, 
      <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> action, 
      <span style="color:#ff3333; font-weight:bold;">:user</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> current_user
    <span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Displaying the logs;</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">for</span> log <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#0066ff; font-weight:bold;">@logs</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  &lt;tr&gt;
    &lt;td&gt;<span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#5A0A0A; font-weight:bold;">link_to</span> <span style="color:#006600; font-weight:bold;">&#40;</span>h log.<span style="color:#9900CC;">loggable</span>.<span style="color:#9900CC;">log_name</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:admin</span>, log.<span style="color:#9900CC;">loggable</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>&lt;/td&gt;
    &lt;td&gt;<span style="color:#006600; font-weight:bold;">&lt;%</span>= h log.<span style="color:#9900CC;">loggable_type</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>&lt;/td&gt;
    &lt;td&gt;<span style="color:#006600; font-weight:bold;">&lt;%</span>= h log.<span style="color:#9900CC;">action</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>&lt;/td&gt;
     &lt;td&gt;<span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#5A0A0A; font-weight:bold;">link_to</span> <span style="color:#006600; font-weight:bold;">&#40;</span>h log.<span style="color:#9900CC;">user</span>.<span style="color:#9900CC;">display_name</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:admin</span>, log.<span style="color:#9900CC;">user</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>&lt;/td&gt;
    &lt;td&gt;<span style="color:#006600; font-weight:bold;">&lt;%</span>= log.<span style="color:#9900CC;">created_at</span>.<span style="color:#5A0A0A; font-weight:bold;">to_s</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>&lt;/td&gt;
  &lt;/tr&gt;
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://cameronyule.com/2008/10/auditing-models-with-user_stamp/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mailbuild gem 1.1</title>
		<link>http://cameronyule.com/2008/09/mailbuild-gem-1-1</link>
		<comments>http://cameronyule.com/2008/09/mailbuild-gem-1-1#comments</comments>
		<pubDate>Wed, 03 Sep 2008 11:49:49 +0000</pubDate>
		<dc:creator>Cameron</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[mailbuild]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubygem]]></category>

		<guid isPermaLink="false">http://cameronyule.com/?p=235</guid>
		<description><![CDATA[I've pushed a small update to the <a href="http://rubyforge.org/projects/mailbuild/">Mailbuild gem</a> this morning which adds support for multiple subscriber lists, enabling you to manage different types of subscribers from within your application.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve pushed a small update to the <a href="http://rubyforge.org/projects/mailbuild/">Mailbuild gem</a> this morning which adds support for multiple subscriber lists, enabling you to manage different types of subscribers from within your application.</p>
<p>The <a href="http://github.com/cameronyule/mailbuild-example/tree">sample Rails application</a> has also been updated to take into account the slightly changed syntax for specifying your list id(s);</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">Mailbuild.<span style="color:#9900CC;">list_id</span> = <span style="color:#996600;">'LIST_ID_HERE'</span></pre></div></div>

<p>…is now…</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">Mailbuild.<span style="color:#9900CC;">list_ids</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>:newsletter = <span style="color:#996600;">'LIST_ID_HERE'</span><span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>All API calls take a list id as their last parameter, which defaults to the first id you declare in the list_ids hash. </p>
<p>You can use a specific subscriber list id as follows;</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">Mailbuild.<span style="color:#5A0A0A; font-weight:bold;">add</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:email</span><span style="color:#006600; font-weight:bold;">&#93;</span>, params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:name</span><span style="color:#006600; font-weight:bold;">&#93;</span>, Mailbuild.<span style="color:#9900CC;">list_ids</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:newsletter</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>The <a href="http://mailbuild.rubyforge.org/">documentation</a> explains what parameters each method accepts.</p>
]]></content:encoded>
			<wfw:commentRss>http://cameronyule.com/2008/09/mailbuild-gem-1-1/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ISOdata Rails plugin</title>
		<link>http://cameronyule.com/2008/08/isodata-rails-plugin</link>
		<comments>http://cameronyule.com/2008/08/isodata-rails-plugin#comments</comments>
		<pubDate>Tue, 05 Aug 2008 18:39:14 +0000</pubDate>
		<dc:creator>Cameron</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[iso]]></category>
		<category><![CDATA[iso3166]]></category>
		<category><![CDATA[iso639]]></category>
		<category><![CDATA[l10n]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://cameronyule.com/?p=154</guid>
		<description><![CDATA[For anyone working on a Rails application which deals with countries or languages, the official source of data is the International Standards Association, specifically ISO 3166 for countries and ISO 639 for languages. To make it easier to get this data into your Rails application, I&#8217;ve created two generators which automatically create the models, migrations [...]]]></description>
			<content:encoded><![CDATA[<p>For anyone working on a Rails application which deals with countries or languages, the official source of data is the <a href="http://www.iso.org/">International Standards Association</a>, specifically ISO 3166 for countries and ISO 639 for languages.</p>
<p>To make it easier to get this data into your Rails application, I&#8217;ve created two generators which automatically create the models, migrations and data you&#8217;ll need and bundled them up in a handy <a href="http://github.com/cameronyule/isodata/tree/master">Rails plug-in</a>.</p>
<p>Usage couldn&#8217;t be simpler…</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">script<span style="color: #000000; font-weight: bold;">/</span>plugin <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>cameronyule<span style="color: #000000; font-weight: bold;">/</span>isodata.git</pre></div></div>

<p>If you want country data…</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">script<span style="color: #000000; font-weight: bold;">/</span>generate countries
rake db:migrate
rake isodata:db:countries</pre></div></div>

<p>…and for languages…</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">script<span style="color: #000000; font-weight: bold;">/</span>generate languages
rake db:migrate
rake isodata:db:languages</pre></div></div>

<p>Check out the <a href="http://github.com/cameronyule/isodata/tree/master">isodata project</a> on Github.</p>
]]></content:encoded>
			<wfw:commentRss>http://cameronyule.com/2008/08/isodata-rails-plugin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails 2.1 SWFUpload Example</title>
		<link>http://cameronyule.com/2008/07/rails-21-swfupload-example</link>
		<comments>http://cameronyule.com/2008/07/rails-21-swfupload-example#comments</comments>
		<pubDate>Thu, 31 Jul 2008 11:39:18 +0000</pubDate>
		<dc:creator>Cameron</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[attachment_fu]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[restful-authentication]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[swfupload]]></category>

		<guid isPermaLink="false">http://cameronyule.com/?p=142</guid>
		<description><![CDATA[There&#8217;s been a few posts lately on getting SWFUpload working with Rails 2.1, attachment_fu and the restful-authentication plugins. To try and make things easier, I&#8217;ve made a sample &#8211; albeit basic &#8211; Rails application to show other people how I managed it. I&#8217;ve created a project on Github to host it, feel free to check [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s been a few posts lately on getting <a href="http://swfupload.org/">SWFUpload</a> working with Rails 2.1, attachment_fu and the restful-authentication plugins. </p>
<p>To try and make things easier, I&#8217;ve made a sample &#8211; albeit basic &#8211; Rails application to show other people how I managed it.</p>
<p>I&#8217;ve <a href="http://github.com/cameronyule/swfupload-rails-authentication/tree/master">created a project</a> on Github to host it, feel free to check it out and let me know how you get on. The only instructions you should need are in the README file, but feel free to leave comments here if you do need a hand.</p>
]]></content:encoded>
			<wfw:commentRss>http://cameronyule.com/2008/07/rails-21-swfupload-example/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>A Ruby/Rails interface to Mailbuild API</title>
		<link>http://cameronyule.com/2008/07/a-rubyrails-interface-to-mailbuild-api</link>
		<comments>http://cameronyule.com/2008/07/a-rubyrails-interface-to-mailbuild-api#comments</comments>
		<pubDate>Thu, 24 Jul 2008 16:19:17 +0000</pubDate>
		<dc:creator>Cameron</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[mailbuild]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubygem]]></category>

		<guid isPermaLink="false">http://cameronyule.com/?p=103</guid>
		<description><![CDATA[I&#8217;m pleased to announce the release of the first version of my Mailbuild API interface, which I&#8217;m distributing as a Rubygem. To make it easier to figure out how to use it, I&#8217;ve also created a fully functional Rails application which demonstrates all the API calls available. To use it all you have to do [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m pleased to announce the release of the first version of my <a href="http://rubyforge.org/projects/mailbuild/">Mailbuild API interface</a>, which I&#8217;m distributing as a Rubygem.</p>
<p>To make it easier to figure out how to use it, I&#8217;ve also created a fully functional Rails application which demonstrates all the API calls available. </p>
<p>To use it all you have to do is grab a copy from subversion…</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> http:<span style="color: #000000; font-weight: bold;">//</span>mailbuild.rubyforge.org<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>rails_mailbuild_example<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>… make sure you have the mailbuild gem installed …</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> rails_mailbuild_example
<span style="color: #666666; font-style: italic;"># OS X/Linux users may have to prefix this with sudo</span>
rake gems:<span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>… and edit config/initializers/mailbuild.rb, adding your own API key, List ID and sub-domain.</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># You can get this information from your Mailbuild admin</span>
Mailbuild.<span style="color:#9900CC;">api_key</span> = <span style="color:#996600;">''</span>
Mailbuild.<span style="color:#9900CC;">list_id</span> = <span style="color:#996600;">''</span>
Mailbuild.<span style="color:#9900CC;">subdomain</span> = <span style="color:#996600;">''</span></pre></div></div>

<p>Hopefully that&#8217;s all there is to it, but if you run into any problems feel free to add a <a href="http://rubyforge.org/tracker/?atid=16671&#038;group_id=4326&#038;func=browse">support request</a> or <a href="http://rubyforge.org/tracker/?atid=16670&#038;group_id=4326&#038;func=browse">bug report</a> on Rubyforge.</p>
]]></content:encoded>
			<wfw:commentRss>http://cameronyule.com/2008/07/a-rubyrails-interface-to-mailbuild-api/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make Rails Engines 2 reload in development mode</title>
		<link>http://cameronyule.com/2008/07/make-rails-engines-2-reload-in-development-mode</link>
		<comments>http://cameronyule.com/2008/07/make-rails-engines-2-reload-in-development-mode#comments</comments>
		<pubDate>Wed, 23 Jul 2008 19:25:01 +0000</pubDate>
		<dc:creator>Cameron</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[engines]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[reload]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://cameronyule.com/?p=88</guid>
		<description><![CDATA[Update 2 I&#8217;m now using a simpler method which appears to be working &#8211; albeit with one caveat, which is due to a conflict between the Asset Packager plug-in and the Engines AssetHelpers extensions (I&#8217;ve simply disabled those extensions). In config/environments/development.rb: config.after_initialize &#123; Dependencies.load_once_paths = &#91;&#93; &#125; Tip found on this ticket on the old [...]]]></description>
			<content:encoded><![CDATA[<div class="notice">
<h3>Update 2</h3>
<p>I&#8217;m now using a simpler method which appears to be working &#8211; albeit with one caveat, which is due to a conflict between the <a href="http://synthesis.sbecker.net/pages/asset_packager">Asset Packager</a> plug-in and the Engines <a href="http://api.rails-engines.org/classes/Engines/RailsExtensions/AssetHelpers.html">AssetHelpers</a> extensions (I&#8217;ve simply disabled those extensions).</p>
</div>
<p>In config/environments/development.rb:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">config.<span style="color:#9900CC;">after_initialize</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
  Dependencies.<span style="color:#9900CC;">load_once_paths</span> = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>Tip found on this <a href="http://dev.rubyonrails.org/ticket/10488">ticket</a> on the old Rails Trac.</p>
<hr />
<div class="notice">
<h3>Update</h3>
<p>I&#8217;ve since stopped using this method. While it did allow for everything short of library files to be reloaded between requests, making the development process far less painful, I ran into a problem with ActiveRecord where deeply-nested (3 associations) models were behaving strangely on reload (they&#8217;d work fine first time, but not afterwards). </p>
</div>
<hr />
<p>Since moving to Rails/Engines 2.1, I&#8217;ve been irritated with having to restart Mongrel each time I make a change to a controller or model in my engine. This wasn&#8217;t an issue in Engines 1.2 as it had a load of custom initialisation code, but with 2.x moving closer to the way Rails itself works &#8211; see this post on the <a href="http://weblog.techno-weenie.net/2007/1/26/understanding-the-rails-plugin-initialization-process">rails plugin initialization process</a> by Rick Olson for more details &#8211; it&#8217;s become a problem.</p>
<p>Unfortunately the solution Rick proposed in his post wasn&#8217;t working for me, but <a href="http://lists.rails-engines.org/htdig.cgi/engine-developers-rails-engines.org/2007-December/000199.html">a thread</a> on the Engines development mailing list has provided a solution &#8211; add the following to the init.rb file of your engine and you&#8217;ll no longer have to restart your web server to see changes in your files.</p>
<p>I&#8217;ve wrapped the code in a check to see if we&#8217;re running in the development environment, as in the majority of cases you&#8217;ll want things to work as normal in production.</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">if</span> Rails.<span style="color:#9900CC;">env</span> == <span style="color:#996600;">'development'</span>
  <span style="color:#6666ff; font-weight:bold;">Rails::Plugin</span>.<span style="color:#9900CC;">class_eval</span> <span style="color:#9966CC; font-weight:bold;">do</span>
     <span style="color:#9966CC; font-weight:bold;">def</span> reloadable!
       load_paths.<span style="color:#5A0A0A; font-weight:bold;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>p<span style="color:#006600; font-weight:bold;">|</span> Dependencies.<span style="color:#9900CC;">load_once_paths</span>.<span style="color:#5A0A0A; font-weight:bold;">delete</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">p</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
     <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  reloadable!
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://cameronyule.com/2008/07/make-rails-engines-2-reload-in-development-mode/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Internationalisation in edge Rails</title>
		<link>http://cameronyule.com/2008/07/internationalisation-in-edge-rails</link>
		<comments>http://cameronyule.com/2008/07/internationalisation-in-edge-rails#comments</comments>
		<pubDate>Wed, 23 Jul 2008 12:11:16 +0000</pubDate>
		<dc:creator>Cameron</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[globalite]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[internationalisation]]></category>
		<category><![CDATA[l10n]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://cameronyule.com/?p=82</guid>
		<description><![CDATA[After the announcement yesterday that Rails 2.2 will have support for internationalisation (i18n) in the core, I read the linked articles and was slightly surprised that rather than unifying/replacing the i18n plugins currently available, it will actually provide an API which makes creating a back-end for handling your locales easier. I&#8217;ve been using Globalite in the Rails [...]]]></description>
			<content:encoded><![CDATA[<p>After the announcement yesterday that Rails 2.2 will have <a href="http://weblog.rubyonrails.org/2008/7/20/internationalization-in-edge-rails-and-more">support for internationalisation</a> (i18n) in the core, I read the linked articles and was slightly surprised that rather than unifying/replacing the i18n plugins currently available, it will actually provide an API which makes creating a back-end for handling your locales easier.</p>
<p>I&#8217;ve been using <a href="http://github.com/mattetti/globalite/tree/master">Globalite</a> in the Rails project I&#8217;m working on and while it&#8217;s the best solution I&#8217;ve tried, I was always frustrated by the use of YAML for it&#8217;s locale files. Thankfully the changes in Rails 2.2 will likely mean a move to pure Ruby locale files, introducing the benefits of namespaces and the ability to override/extend generic files with site-specific ones.</p>
<p>Now we just have to wait a few months for the release and see what plugins adapt/appear to take advantage of it.</p>
]]></content:encoded>
			<wfw:commentRss>http://cameronyule.com/2008/07/internationalisation-in-edge-rails/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

