<?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>Rob@Rojotek &#187; Ruby</title>
	<atom:link href="http://www.rojotek.com/blog/blog/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rojotek.com/blog</link>
	<description>Software Development in Brisbane</description>
	<lastBuildDate>Wed, 25 Jan 2012 10:34:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>How to get OpenSSL in Ruby 1.9.3 working on OSX 10.7 (fixing the Segmentation Fault with Ruby OpenSSL)</title>
		<link>http://www.rojotek.com/blog/2012/01/20/how-to-get-openssl-in-ruby-1-9-3-working-on-osx-10-7-fixing-the-segmentation-fault-with-ruby-openssl/</link>
		<comments>http://www.rojotek.com/blog/2012/01/20/how-to-get-openssl-in-ruby-1-9-3-working-on-osx-10-7-fixing-the-segmentation-fault-with-ruby-openssl/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 04:38:25 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.rojotek.com/blog/?p=1115</guid>
		<description><![CDATA[update &#8211; this needs to have a recent version of RVM &#8211; it works with rvm 1.10 but not with 1.6 &#8211; do an rvm update first. When using the mighty cobweb web crawler on my OSX 10.7 with Ruby 1.9.3 I was getting a seg fault in net http: net/http.rb:799: [BUG] Segmentation fault A [...]]]></description>
			<content:encoded><![CDATA[<p><em>update &#8211; this needs to have a recent version of RVM &#8211; it works with rvm 1.10 but not with 1.6 &#8211; do an rvm update first.</em></p>
<p>When using the mighty <a href="https://github.com/stewartmckee/cobweb">cobweb</a> web crawler on my OSX 10.7 with Ruby 1.9.3 I was getting a seg fault in net http:</p>
<p>net/http.rb:799: [BUG] Segmentation fault</p>
<p>A bit of googling and isolation in IRB showed that this can be caused when hitting HTTPS urls using net http.</p>
<p>I saw a few different solutions to the problem, primarily talking about Ruby 1.9.2.Surprisingly it took me a while to end up at the RVM documentation about the problem: <a href="https://rvm.beginrescueend.com/packages/openssl/">https://rvm.beginrescueend.com/packages/openssl/</a>. This didn&#8217;t quite work out of the box for me, so I used the solution in the following gist.</p>
<p><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;"><div class="gistem"><div id="gist-1645188" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'>rvm pkg install openssl</div><div class='line' id='LC2'>rvm remove 1.9.3</div><div class='line' id='LC3'>rvm install 1.9.3 --with-openssl-dir<span class="o">=</span><span class="nv">$rvm_path</span>/usr --with-gcc<span class="o">=</span>clang</div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1645188/468fda61e63a13524d376994a969bcf3d67be620/file1.sh" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1645188#file_file1.sh" style="float:right;margin-right:10px;color:#666">file1.sh</a>
            <a href="https://gist.github.com/1645188">This Gist</a> is brought to you using <a href="http://en.bainternet.info/2011/simple-gist-embed"><small>Simple Gist Embed</small></a>.
          </div>
        </div>
</div>
</div><style type="text/css">@import "http://gist.github.com/stylesheets/gist/embed.css"; .gistem .highlight {background: inherit; !important;}</style></span></p>
<p>and now I can happily crawl https urls.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rojotek.com/blog/2012/01/20/how-to-get-openssl-in-ruby-1-9-3-working-on-osx-10-7-fixing-the-segmentation-fault-with-ruby-openssl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Two tricks for getting Backbone.js to play well with Ruby on Rails</title>
		<link>http://www.rojotek.com/blog/2011/11/29/two-tricks-for-getting-backbone-to-play-well-with-ruby-on-rails/</link>
		<comments>http://www.rojotek.com/blog/2011/11/29/two-tricks-for-getting-backbone-to-play-well-with-ruby-on-rails/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 07:17:18 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.rojotek.com/blog/?p=1097</guid>
		<description><![CDATA[Backbone.js is a great library for creating single page applications that consume RESTful JSON services. Ruby on Rails does well at generating RESTful APIs and speaking JSON. In order to get the Rails working really well with Backbone, there are two tricks to do. First, add the following line to the application controller to make [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://documentcloud.github.com/backbone/">Backbone.js</a> is a great library for creating single page applications that consume RESTful JSON services.  Ruby on Rails does well at generating RESTful APIs and speaking JSON.  In order to get the Rails working really well with Backbone, there are two tricks to do.</p>
<p>First, add the following line to the application controller to make the output look like what backbone expects.</p>
<div class="gistem"><div id="gist-1403791" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="o">.</span><span class="n">.</span><span class="o">.</span></div><div class='line' id='LC2'><span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Base</span><span class="o">.</span><span class="n">include_root_in_json</span> <span class="o">=</span> <span class="kp">false</span></div><div class='line' id='LC3'><span class="o">.</span><span class="n">.</span><span class="o">.</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1403791/11a2ea69dfd6a674645fa1091330ce1acab317da/application.rb" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1403791#file_application.rb" style="float:right;margin-right:10px;color:#666">application.rb</a>
            <a href="https://gist.github.com/1403791">This Gist</a> is brought to you using <a href="http://en.bainternet.info/2011/simple-gist-embed"><small>Simple Gist Embed</small></a>.
          </div>
        </div>
</div>
</div>
<p>Second take advantage of the : only option in to_json to limit the attributes included in the serialised json object.  The documentation for this isn&#8217;t quite there in the latest rails, but the 2.3 to_json method describes it. <a href="http://apidock.com/rails/ActiveRecord/Serialization/to_json">http://apidock.com/rails/ActiveRecord/Serialization/to_json</a>.</p>
<div class="gistem"><div id="gist-1403824" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="c1"># code to retrieve the collection - the to_json filtering works on a collection, or a single model record</span></div><div class='line' id='LC2'><span class="n">render</span> <span class="ss">:json</span> <span class="o">=&gt;</span> <span class="n">collection</span><span class="o">.</span><span class="n">to_json</span><span class="p">(</span><span class="ss">:only</span> <span class="o">=&gt;</span> <span class="o">[</span> <span class="ss">:id</span><span class="p">,</span> <span class="ss">:name</span><span class="p">,</span> <span class="ss">:another_attribute</span><span class="o">]</span><span class="p">)</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1403824/81eee11a12dc1a75f5b5100757239d1c5958dffc/controller.rb" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1403824#file_controller.rb" style="float:right;margin-right:10px;color:#666">controller.rb</a>
            <a href="https://gist.github.com/1403824">This Gist</a> is brought to you using <a href="http://en.bainternet.info/2011/simple-gist-embed"><small>Simple Gist Embed</small></a>.
          </div>
        </div>
</div>
</div>
<p>With these two simple tricks rails will generate the json that backbone wants, and you&#8217;ll have a happy front-end developer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rojotek.com/blog/2011/11/29/two-tricks-for-getting-backbone-to-play-well-with-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Updating RubyGems in OSX 10.5.7</title>
		<link>http://www.rojotek.com/blog/2009/05/27/updating-rubygems-in-os-x/</link>
		<comments>http://www.rojotek.com/blog/2009/05/27/updating-rubygems-in-os-x/#comments</comments>
		<pubDate>Wed, 27 May 2009 05:15:54 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[RubyGems]]></category>

		<guid isPermaLink="false">http://www.rojotek.com/blog/?p=871</guid>
		<description><![CDATA[.7When recently trying to install Sinatra via RubyGems, I got a message that RubyGems was out of date. I figured that gem would be smart enough to have an easy upgrade command, so there had to be a command to easily upgrade. Naturally there is: 1&#60;span style=&#34; background-color: #ffffcc;&#34;&#62;gem update --system&#60;/span&#62; I only found this [...]]]></description>
			<content:encoded><![CDATA[<p>       .7When recently trying to install <a href="http://www.sinatrarb.com">Sinatra</a> via RubyGems, I got a message that RubyGems was out of date. I figured that gem would be smart enough to have an easy upgrade command, so there had to be a command to easily upgrade. Naturally there is:    </p>
<p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;span style=&quot; background-color: #ffffcc;&quot;&gt;gem update --system&lt;/span&gt;</div></td></tr></tbody></table></div>
</p>
<p>       I only found this when looking through google, and I got a series of pages warning to be careful when using</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;span style=&quot; background-color: #ffffcc;&quot;&gt;gem update --system&lt;/span&gt;</div></td></tr></tbody></table></div>
<p>as it can kill existing gems (<a href="http://puctuatedproductivity.com/2007/11/01/unistalling-ruby-installed-by-source-on-os-x">http://puctuatedproductivity.com/2007/11/01/unistalling-ruby-installed-by-source-on-os-x</a>, <a href="http://thenoobonrails.blogspot.com/2008/06/doing-gem-update-system-might-lose-all.html">http://thenoobonrails.blogspot.com/2008/06/doing-gem-update-system-might-lose-all.html</a>) so I was a bit nervous. &#160;Since I have a periodic use of ruby and&#160;I&#39;m lazy enough to make Larry Wall proud, I figured I&#39;d take a punt on just using</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;span style=&quot; background-color: #ffffcc;&quot;&gt;gem update --system&lt;/span&gt;</div></td></tr></tbody></table></div>
<p>. &#160;Turns out it just works, and I&#39;ve kept all my old gems. &#160;Hooray. &#160;Given that the posts talking about issues are old, I&#39;m either assuming that they&#39;ve done things differently to me, or things have been fixed since then&#8230; so&#8230; if you need to update gems due to a message:    </p>
<blockquote><p>      ERROR: Error installing sinatra:<br />       fastthread requires RubyGems version &#62;= 1.2    </p></blockquote>
<p>       or similar, just use</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;span style=&quot; background-color: #ffffcc;&quot;&gt;gem update --system&lt;/span&gt;</div></td></tr></tbody></table></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rojotek.com/blog/2009/05/27/updating-rubygems-in-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

