<?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>Chris Irish &#124; Ruby, Rails, Javascript Developer &#124; Phoenix, AZ &#187; Ruby</title>
	<atom:link href="http://www.christopherirish.com/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.christopherirish.com</link>
	<description>Ruby, Rails, Javascript, all things web development related</description>
	<lastBuildDate>Mon, 19 Jan 2026 07:43:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>How to install RVM on Ubuntu 10.04</title>
		<link>http://www.christopherirish.com/2010/08/25/how-to-install-rvm-on-ubuntu-10-04/</link>
		<comments>http://www.christopherirish.com/2010/08/25/how-to-install-rvm-on-ubuntu-10-04/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 08:21:09 +0000</pubDate>
		<dc:creator>Irish</dc:creator>
				<category><![CDATA[Installation]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[RVM]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.christopherirish.com/?p=474</guid>
		<description><![CDATA[I&#8217;ve heard people describe frustrations they had in getting Rails 3 setup on Ubuntu 10.04 with Ruby 1.9.2. I&#8217;m going to outline the steps I&#8217;ve taken to do this. Let&#8217;s get started installing RVM. It should be noted that I created a fresh slice on my Rackspace Cloud account to create this tutorial. And I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I&#8217;ve heard people describe frustrations they had in getting Rails 3 setup on Ubuntu 10.04 with Ruby 1.9.2.  I&#8217;m going to outline the steps I&#8217;ve taken to do this.  Let&#8217;s get started installing RVM.</p>
<p>It should be noted that I created a fresh slice on my <a href="http://www.rackspacecloud.com/1655-0-3-13.html" target="_blank">Rackspace Cloud</a> account to create this tutorial.  And I&#8217;m assuming you&#8217;ve already setup SSH.</p>

<div class="wp-terminal">$ ssh root@173.XXX.XXX.XXX<br/>&lt;-- Output Snipped --&gt;<br/>root@173.XXX.XXX.XXX's password:<br/>&lt;-- Output Snipped --&gt;<br/></div>

<p>Alright, so lets confirm we don&#8217;t have ruby installed</p>

<div class="wp-terminal">$ which ruby<br/>$ <br/></div>

<p>Cool, nada.  Let&#8217;s grab the basic dependencies</p>

<div class="wp-terminal">$ sudo apt-get install curl git-core ruby<br/>Reading package lists... Done<br/>Building dependency tree<br/>&lt;-- Output Snipped --&gt;<br/></div>

<p>Now we&#8217;ll install RVM as per their instructions</p>
<p>http://rvm.beginrescueend.com/rvm/install/</p>

<div class="wp-terminal">$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )<br/><br/>&lt;-- Output Snipped --&gt;<br/><br/>RVM:   shell scripts which allow management of multiple ruby interpreters and environments.<br/>RTFM:  http://rvm.beginrescueend.com/<br/>HELP:  http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)<br/><br/>* Installing rvm to /usr/local/rvm/<br/>Correct permissions for base binaries in /usr/local/bin...<br/>Copying manpages into place.<br/><br/>Notes for Linux ( DISTRIB_ID=Ubuntu<br/>DISTRIB_RELEASE=10.04<br/>DISTRIB_CODENAME=lucid<br/>DISTRIB_DESCRIPTION="Ubuntu 10.04 LTS" )<br/><br/>&lt;-- Output Snipped --&gt;<br/><br/>*  For JRuby (if you wish to use it) you will need:<br/>$ aptitude install curl sun-java6-bin sun-java6-jre sun-java6-jdk<br/>*  For MRI &amp; ree (if you wish to use it) you will need (depending on what you are installing):<br/>$ aptitude install build-essential bison openssl libreadline5 libreadline-dev curl git-core zlib1g zlib1g-dev libssl-dev vim libsqlite3-0 libsqlite3-dev sqlite3 libreadline-dev libxml2-dev git-core subversion autoconf<br/>*  For IronRuby (if you wish to use it) you will need:<br/>$ aptitude install curl mono-2.0-devel<br/><br/>&lt;-- Output Snipped --&gt;<br/><br/>WARNING:  you have a 'return' statement in your .bashrc, likely this will cause untold havoc.<br/>This means that if you see '[ -z "$PS1" ] &amp;&amp; return' then you must change this line to:<br/>if [[ -n "$PS1" ]] ; then<br/>... original content that was below the &amp;&amp; return line ...<br/>fi # &lt;= be sure to close the if.<br/>#EOF .bashrc<br/>Even if you use zsh you should still adjust the .bashrc as above.<br/>If you have any questions about this please visit #rvm on irc.freenode.net.<br/><br/>Installation of RVM to /usr/local/rvm/ is complete.<br/></div>

<p>The last part in there about the .bashrc file is important!  Using your editor of choice, open the .bashrc file that resides in your user directory.</p>
<p>You need to replace the line that says</p>
<pre>[ -z "$PS1" ] &amp;&amp; return</pre>
<p>with</p>
<pre>if [[ -n "$PS1" ]]; then</pre>
<p>Now add this to the last line of the file</p>
<pre>if [[ -s $HOME/.rvm/scripts/rvm ]] ; then source $HOME/.rvm/scripts/rvm ; fi

fi</pre>
<p>And yes there needs to be that last fi as it closes the one we added earlier. Save this file with our changes.  Now we can check if RVM is setup correctly.</p>

<div class="wp-terminal">$ rvm notes<br/></div>

<p>If this doesn&#8217;t work you may have to source your .bashrc file to have it reloaded by the current terminal session</p>

<div class="wp-terminal">$ source ~/.bashrc<br/></div>

<p>After running `rvm notes` if it gives you installation notes about RVM then you&#8217;re good to continue, otherwise double check you edited your .bashrc file correctly.</p>
<p>In the notes output RVM tells you what packages you&#8217;re gonna need to install for various flavors of Ruby.  Since we&#8217;re going with 1.9.2 we want the packages it lists under the MRI &#038; ree section.  Let&#8217;s install those now.</p>

<div class="wp-terminal">$ sudo aptitude install build-essential bison openssl libreadline5 libreadline-dev curl git-core zlib1g zlib1g-dev libssl-dev vim libsqlite3-0 libsqlite3-dev sqlite3 libreadline-dev libxml2-dev git-core subversion autoconf<br/><br/>&lt;-- A really long bit of Output Snipped --&gt;<br/><br/></div>

<p>Now we can look at all the RVM known Ruby packages</p>

<div class="wp-terminal">$ rvm list known<br/># MRI Rubies<br/>(ruby-)1.8.6(-p399)<br/>(ruby-)1.8.6-head<br/>(ruby-)1.8.7(-p302)<br/>(ruby-)1.8.7-head<br/>(ruby-)1.9.1-p243<br/>(ruby-)1.9.1-p376<br/>(ruby-)1.9.1(-p429)<br/>(ruby-)1.9.1-head<br/>(ruby-)1.9.2-preview1<br/>(ruby-)1.9.2-preview3<br/>(ruby-)1.9.2-rc1<br/>(ruby-)1.9.2-rc2<br/>(ruby-)1.9.2(-p0)<br/>(ruby-)1.9.2-head<br/>ruby-head<br/><br/># JRuby<br/>jruby-1.2.0<br/>jruby-1.3.1<br/>jruby-1.4.0<br/>jruby-1.5.1<br/>jruby(-1.5.2)<br/>jruby-head<br/><br/>&lt;-- Output Snipped --&gt;<br/></div>

<p>Next we install the version we want and set it as the default.  You&#8217;re gonna see RVM install ruby-1.8.7-p302 first, be patient as it will need to also install rubygems-1.3.7, before it finally gets to that 1.9.2.</p>

<div class="wp-terminal">$ rvm install 1.9.2-head<br/>&lt;-- Output Snipped --&gt;<br/>info: Installing ruby-1.8.7-p302<br/>&lt;-- Output Snipped --&gt;<br/>info: Installing rubygems dedicated to ruby-1.8.7-p302...<br/>&lt;-- Output Snipped --&gt;<br/>info: Installing ruby-1.9.2-head<br/>&lt;-- Output Snipped --&gt;<br/>info: Updating rubygems for /usr/local/rvm/gems/ruby-1.9.2-head<br/></div>


<div class="wp-terminal">$ rvm --default 1.9.2-head<br/>$ ruby -v<br/>$ ruby 1.9.2p0 (2010-08-18 revision 29034) [x86_64-linux]<br/><br/></div>

<p>Good to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherirish.com/2010/08/25/how-to-install-rvm-on-ubuntu-10-04/feed/</wfw:commentRss>
		<slash:comments>78</slash:comments>
		</item>
		<item>
		<title>The Ruby %r{} expression</title>
		<link>http://www.christopherirish.com/2010/08/12/the-ruby-r-expression/</link>
		<comments>http://www.christopherirish.com/2010/08/12/the-ruby-r-expression/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 08:13:27 +0000</pubDate>
		<dc:creator>Irish</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Regular Expressions]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.christopherirish.com/?p=430</guid>
		<description><![CDATA[Tonight I was reading over some Ruby code in a gem I&#8217;m currently using and came across this line: 1 string = mode.to_s 2 string.gsub!(%r{(^.)&#124;(_.)}) { &#124;m&#124; m[m.length-1,1].upcase } 3 Two things struck me about that second line. For one I&#8217;ve never used gsub and passed it a block, thats cool. And two, what is [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Tonight I was reading over some Ruby code in a gem I&#8217;m currently using and came across this line:</p>
<pre class="textmate-source sunburst"><span class='linenum'>    1</span> <span class="source source_ruby">string <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> mode<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>to_s
<span class='linenum'>    2</span> string<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>gsub!<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="string string_regexp string_regexp_mod-r string_regexp_mod-r_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">%r{</span><span class="string string_regexp string_regexp_group string_regexp_group_ruby"><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">(</span>^.<span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">)</span></span>|<span class="string string_regexp string_regexp_group string_regexp_group_ruby"><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">(</span>_.<span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">)</span></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">}</span></span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span> <span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby">{</span><span class="meta meta_syntax meta_syntax_ruby meta_syntax_ruby_start-block"> </span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span><span class="variable variable_other variable_other_block variable_other_block_ruby">m</span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span> m<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span>m<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>length<span class="keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby">-</span><span class="constant constant_numeric constant_numeric_ruby">1</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span><span class="constant constant_numeric constant_numeric_ruby">1</span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>upcase <span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby">}</span>
</span><span class='linenum'>    3</span> </pre>
<p>Two things struck me about that second line.  For one I&#8217;ve never used gsub and passed it a block, thats cool.  And two, what is %r{} ? I&#8217;ve never seen that before.  It turns out that in Ruby, the /&#8230;/ or %r&#8230; literals, and using the Regexp.new constructor are all the same thing.  All ways of created a regular expression.  I still think I prefer the look of the simple slashes /&#8230;/ though.</p>
<div id="hire" class="text-center">
  <a href="http://velocitylabs.io"><img src="http://www.christopherirish.com/wp-content/uploads/2018/07/velocity-labs-logo-text.png" alt="" title="velocity-labs-logo-text" width="300" class="alignleft size-full wp-image-971" /></a></p>
<p>
    Need web application development, maintenance for your existing app, or a third party code review?
  </p>
<p>
    <strong class="text-uppercase">Velocity Labs can help.</strong>
  </p>
<p>  <a href="http://velocitylabs.io#contact" class="btn btn-warning btn-block" target="_blank">Click here to get started!</a>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherirish.com/2010/08/12/the-ruby-r-expression/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Ruby 1.8.7 openssl Bus Error</title>
		<link>http://www.christopherirish.com/2010/06/21/ruby-1-8-7-openssl-bus-error/</link>
		<comments>http://www.christopherirish.com/2010/06/21/ruby-1-8-7-openssl-bus-error/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 15:00:37 +0000</pubDate>
		<dc:creator>Irish</dc:creator>
				<category><![CDATA[Installation]]></category>
		<category><![CDATA[OpenSSL]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[RVM]]></category>

		<guid isPermaLink="false">http://www.christopherirish.com/?p=333</guid>
		<description><![CDATA[Recently I switched from using my local ruby install to using RVM for managing all my ruby installations. RVM is pretty awesome and I highly recommend it. I went ahead and installed a few versions of ruby that I&#8217;d like to use including, ruby 1.8.7 (for work projects) and 1.9.2 (for playing with rails 3). [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Recently I switched from using my local ruby install to using RVM for managing all my ruby installations.  RVM is pretty awesome and I highly recommend it.  I went ahead and installed a few versions of ruby that I&#8217;d like to use including, ruby 1.8.7 (for work projects) and 1.9.2 (for playing with rails 3).</p>
<p>I came across an issue though with my 1.8.7 install when trying to run a rake db:migrate:reset command with my current work project.  It was along the lines of this:</p>

<div class="wp-terminal">$ rake db:migrate:reset<br/>(in /Users/cirish/Projects/so-ch)<br/>/Users/cirish/.rvm/rubies/ruby-1.8.7-tv1_8_7_173/lib/ruby/1.8/openssl/ssl.rb:31: [BUG] Bus Error<br/>ruby 1.8.7 (2009-06-08 patchlevel 173) [i686-darwin9.8.0]<br/><br/>Abort trap<br/>$ <br/></div>

<p>Well that&#8217;s no bueno.  It turns out that this is happening because, I have two openssl installations.  A system one and other that I installed through macports.  The reason the bus error is being thrown is that my eventmachine gem wasn&#8217;t compiled with the same openssl lib as my ruby 1.8.7 install.  We can confirm this by running the following:</p>

<div class="wp-terminal">$ ruby -rubygems -e" require 'openssl' "; echo $? 0<br/>0 0<br/><br/>$ ruby -rubygems -e" require 'eventmachine'; require 'openssl' "; echo $?<br/>/Users/cirish/.rvm/rubies/ruby-1.8.7-tv1_8_7_173/lib/ruby/1.8/openssl/ssl.rb:31: [BUG] Bus Error<br/>ruby 1.8.7 (2009-06-08 patchlevel 173) [i686-darwin9.8.0]<br/><br/>Abort trap<br/>134<br/><br/></div>

<p>At this point you could either recompile ruby and point it to the correct openssl lib or recompile eventmachine to use the system&#8217;s openssl.  Since this was a new ruby install anyways, I chose to just recompile ruby.</p>

<div class="wp-terminal">$ rvm install ruby-1.8.7-tv1_8_7_174 --configure --enable-shared=true,--with-openssl-dir=/opt/local --debug<br/></div>

<p>Now let&#8217;s check the install again</p>

<div class="wp-terminal">$ ruby -rubygems -e" require 'eventmachine'; require 'openssl' "; echo $?<br/>0<br/></div>

<p>Fixed <img src='http://www.christopherirish.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherirish.com/2010/06/21/ruby-1-8-7-openssl-bus-error/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Install MySQL gem on Leopard with a macports MySQL</title>
		<link>http://www.christopherirish.com/2010/06/20/install-mysql-gem-for-leopard-using-macports-mysql/</link>
		<comments>http://www.christopherirish.com/2010/06/20/install-mysql-gem-for-leopard-using-macports-mysql/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 15:00:30 +0000</pubDate>
		<dc:creator>Irish</dc:creator>
				<category><![CDATA[Installation]]></category>
		<category><![CDATA[Gem]]></category>
		<category><![CDATA[MacPorts]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.christopherirish.com/?p=336</guid>
		<description><![CDATA[This is more of a reminder to myself than anything. To install the mysql gem on OS X Leopard and use a macports MySQL install. First remove any previously installed mysql gem $ gem uninstall mysql Then install, giving the correct Leopard archflag and macports mysql_config directory $ env ARCHFLAGS="-arch i386" gem install mysql -- [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>This is more of a reminder to myself than anything.  To install the mysql gem on OS X Leopard and use a macports MySQL install.</p>
<p>First remove any previously installed mysql gem</p>

<div class="wp-terminal">$ gem uninstall mysql<br/></div>

<p>Then install, giving the correct Leopard archflag and macports mysql_config directory</p>

<div class="wp-terminal">$ env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config<br/></div>

]]></content:encoded>
			<wfw:commentRss>http://www.christopherirish.com/2010/06/20/install-mysql-gem-for-leopard-using-macports-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Refactor: Ruby Array#joins for delimiting</title>
		<link>http://www.christopherirish.com/2010/04/30/refactor-ruby-arrayjoins-for-delimiting/</link>
		<comments>http://www.christopherirish.com/2010/04/30/refactor-ruby-arrayjoins-for-delimiting/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 15:32:06 +0000</pubDate>
		<dc:creator>Irish</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Refactor]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.christopherirish.com/?p=142</guid>
		<description><![CDATA[The other day I was reviewing a collegue&#8217;s code, who shall remain nameless to protect their innocense, and came across this lil gem: 1 &#60;h4&#62;Tags&#60;/h4&#62; 2 &#60;p&#62; 3 &#60;% @entry.tags.each_with_index do &#124;tag, i&#124; %&#62; 4 &#60;%= tag.name %&#62; &#60;% if @entry.tags.length - 1 != i %&#62;, &#60;% end %&#62; 5 &#60;% end %&#62; 6 &#60;/p&#62; [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>The other day I was reviewing a collegue&#8217;s code, who shall remain nameless to protect their innocense, and came across this lil gem:
</p>
<pre class="textmate-source sunburst">
<span class='linenum'>    1</span> <span class="text text_html text_html_ruby"><span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">h4</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>Tags<span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">h4</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>
<span class='linenum'>    2</span> <span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">p</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>
<span class='linenum'>    3</span>   <span class="source source_ruby source_ruby_rails source_ruby_rails_embedded source_ruby_rails_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%</span> <span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>entry</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>tags<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>each_with_index <span class="keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby">do </span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span><span class="variable variable_other variable_other_block variable_other_block_ruby">tag</span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">,</span> <span class="variable variable_other variable_other_block variable_other_block_ruby">i</span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span> <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span>
<span class='linenum'>    4</span>     <span class="source source_ruby source_ruby_rails source_ruby_rails_embedded source_ruby_rails_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%=</span> tag<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>name <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span> <span class="source source_ruby source_ruby_rails source_ruby_rails_embedded source_ruby_rails_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%</span> <span class="keyword keyword_control keyword_control_ruby">if</span> <span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>entry</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>tags<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>length <span class="keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby">-</span> <span class="constant constant_numeric constant_numeric_ruby">1</span> <span class="keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby">!=</span> i <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span>, <span class="source source_ruby source_ruby_rails source_ruby_rails_embedded source_ruby_rails_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%</span> <span class="keyword keyword_control keyword_control_ruby">end</span> <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span>
<span class='linenum'>    5</span>   <span class="source source_ruby source_ruby_rails source_ruby_rails_embedded source_ruby_rails_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%</span> <span class="keyword keyword_control keyword_control_ruby">end</span> <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span>
<span class='linenum'>    6</span> <span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">p</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span></span></pre>
<p>
Now while it does work, it&#8217;s definately not the Ruby way, as we can rewrite it more elegantly like:
</p>
<pre class="textmate-source sunburst"><span class='linenum'>    1</span> <span class="text text_html text_html_ruby"><span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">h4</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>Tags<span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">h4</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>
<span class='linenum'>    2</span> <span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">p</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>
<span class='linenum'>    3</span>   <span class="source source_ruby source_ruby_rails source_ruby_rails_embedded source_ruby_rails_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%=</span> <span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>entry</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>tags<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>join<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>, <span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span> <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span>
<span class='linenum'>    4</span> <span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">p</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span></span></pre>
<p>
The &#8216;tags&#8217; association here returns an array, so we can just call the join method on it.  This will delimit the array contents with whatever string we like, in this case just a comma.  Ah much better and concise.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherirish.com/2010/04/30/refactor-ruby-arrayjoins-for-delimiting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
