<?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>Big Trapeze &#187; Learning Rails</title>
	<atom:link href="http://bigtrapeze.com/category/learning-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://bigtrapeze.com</link>
	<description>Big Ideas From the Little Guys</description>
	<lastBuildDate>Wed, 16 May 2012 21:31:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Enabling Wildcard SSL on a Heroku Rails App</title>
		<link>http://bigtrapeze.com/2012/05/16/enabling-wildcard-ssl-on-a-heroku-rails-app/</link>
		<comments>http://bigtrapeze.com/2012/05/16/enabling-wildcard-ssl-on-a-heroku-rails-app/#comments</comments>
		<pubDate>Wed, 16 May 2012 21:31:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Learning Rails]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[homepost]]></category>

		<guid isPermaLink="false">http://bigtrapeze.com/?p=339</guid>
		<description><![CDATA[Typically installing SSL is challenging enough, but add Heroku and the need for a wildcard SSL certificate in the mix and you&#8217;ve got bigger issues. Here are the steps to get it done with as little fuss as possible: Purchase a wildcard SSL certificate. I used RapidSSL, and while any will work, Comodo seems to [...]]]></description>
			<content:encoded><![CDATA[<p>Typically installing SSL is challenging enough, but add Heroku and the need for a wildcard SSL certificate in the mix and you&#8217;ve got bigger issues. Here are the steps to get it done with as little fuss as possible:</p>
<ol>
<li>Purchase a wildcard SSL certificate. I used <a href="http://www.rapidssl.com/buy-ssl/wildcard-ssl-certificate/">RapidSSL</a>, and while any will work, <a href="https://dnsimple.com/pricing">Comodo seems to be the one currently recommended by DNSimple</a>, which we&#8217;ll use later in these instructions.</li>
<li>Next, add the <a href="https://devcenter.heroku.com/articles/ssl-endpoint-beta">SSL Endpoint add-on</a> to your app via Heroku. It&#8217;s an additional $20 a month to enable this service, that&#8217;s just the cost-of-doin-bidness with Heroku.</li>
<li>So, at this point, you have your wildcard SSL installed with Heroku. You can tell if you installed it correctly by dropping into the Heroku CLI (which you can install via the <a href="https://toolbelt.heroku.com/">Heroku Toolbelt</a>) and issuing a &#8220;heroku certs&#8221;. This should give you an endpoint, which looks something like:
<p><code>waterfall-9359.herokussl.com</code></p>
<p>You&#8217;ll need your specific endpoint for our next step, so copy it and keep it ready.</li>
<li>Finally, create an account with someone like DNSimple. <a href="http://blog.dnsimple.com/introducing-the-alias-record/" target="_blank">Without an ALIAS service like this</a>, you won&#8217;t be able to enable SSL on your root domain (like <em>myapp.com</em> or <em>www.myapp.com</em>). If you used DNSimple, go to the <em>Advanced Editor </em>for your domain. You&#8217;ll want to add the following:
<p>- an ALIAS record for your root url, <em>myapp.com</em>, which points to your Heroku-issued endpoint, like: <em>waterfall-9359.herokussl.com<br />
</em>- a CNAME record for your <em>www</em>-based url, <em>www.myapp.com</em>, which points to the same endpoint above, like <em>waterfall-9359.herokussl.com<br />
</em>- CNAME records for each subdoman you wish to enable SSL on, like <em>blog.myapp.com</em> or <em>account.myapp.com,</em> each pointing to our Heroku endpoint</li>
<li> That should do it! The next step would be enabling SSL in your app, which is a straightforward process achieved by adding <code>config.force_ssl = true</code> to your application.rb file. (For more details on how to enable it in production only, <a href="http://www.simonecarletti.com/blog/2011/05/configuring-rails-3-https-ssl/" target="_blank">read this excellent blog post from Simone Carletti.</a>)</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://bigtrapeze.com/2012/05/16/enabling-wildcard-ssl-on-a-heroku-rails-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using RABL to Display Multiple Models</title>
		<link>http://bigtrapeze.com/2012/03/22/using-rabl-to-display-multiple-models/</link>
		<comments>http://bigtrapeze.com/2012/03/22/using-rabl-to-display-multiple-models/#comments</comments>
		<pubDate>Thu, 22 Mar 2012 15:29:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Learning Rails]]></category>
		<category><![CDATA[homepost]]></category>
		<category><![CDATA[rabl]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://bigtrapeze.com/?p=306</guid>
		<description><![CDATA[I had a scenario where I needed to show a collection of tweets AND a hash of stats related to those tweets,using RABL, a nice Rails Gem useful for displaying JSON-formatted data. Unfortunately, I couldn&#8217;t find enough good examples on how to do this&#8211;and after some frustrating hours learned that RABL doesn&#8217;t play well with [...]]]></description>
			<content:encoded><![CDATA[<p>I had a scenario where I needed to show a collection of tweets AND a hash of stats related to those tweets,<a href="https://github.com/nesquena/rabl">using RABL, a nice Rails Gem</a> useful for displaying JSON-formatted data. Unfortunately, I couldn&#8217;t find enough good examples on how to do this&#8211;and after some frustrating hours learned that RABL doesn&#8217;t play well with hashes.</p>
<p>In this example I have a model, <em>@tweets</em>, filled with scraped tweets from Twitter. I have a hash, <em>stats</em>, filled with stats about those tweets&#8211;like the total number, the number of tweeters, the number of re-tweets, etc. Ideally, I&#8217;d like my JSON response to look something like:</p>
<p><code>{"stats":{"total":1024,"users":128,"retweets":"32"},"tweets":[{"tweet":"Petrol heads! Tune in to @DiscoveryUK at 9PM for the premiere of brand new #WheelerDealers the series kicks off with a rather nice Fiat Dino"},{"tweet":"2nd last nite in bahamas!  Dinner alone. shark diving done and my camera gear just arrived!!  Thanks a lot Air Canada. Exmas tmrw.  L"}...]}</code></p>
<p>First, in your controller, convert this hash to an OpenStruct format, which uses a RABL-friendly dot notation, like</p>
<p><strong>your_controller.rb</strong></p>
<div class="wp_syntax">
<div class="code">
<pre class="rails" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'ostruct'</span>
<span style="color:#0066ff; font-weight:bold;">@stats</span> = OpenStruct.<span style="color:#5A0A0A; font-weight:bold;">new</span>
<span style="color:#0066ff; font-weight:bold;">@stats</span>.<span style="color:#9900CC;">total</span> = @tweets.<span style="color:#5A0A0A; font-weight:bold;">count</span>
<span style="color:#0066ff; font-weight:bold;">@stats</span>.<span style="color:#9900CC;">users</span> = <span style="color:#996600;">'128'</span>  <span style="color:#008000; font-style:italic;"># Keep adding stats if you'd like</span>
<span style="color:#0066ff; font-weight:bold;">@stats</span>.<span style="color:#9900CC;">retweets</span> = <span style="color:#996600;">'32'</span> <span style="color:#008000; font-style:italic;"># .. more stats</span></pre>
</div>
</div>
<p>Then, in your view file<br />
<strong>your_view_file.rabl</strong></p>
<div class="wp_syntax">
<div class="code">
<pre class="rails" style="font-family:monospace;">object <span style="color:#0000FF; font-weight:bold;">false</span>
&nbsp;
child <span style="color:#0066ff; font-weight:bold;">@stats</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:stats</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    attribute <span style="color:#ff3333; font-weight:bold;">:total</span>, <span style="color:#ff3333; font-weight:bold;">:users</span>, <span style="color:#ff3333; font-weight:bold;">:reteweets</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
child <span style="color:#0066ff; font-weight:bold;">@tweets</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:tweets</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    attributes <span style="color:#ff3333; font-weight:bold;">:tweet</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre>
</div>
</div>
<p>Your result should look like the example output above. Two things to note: 1) I was able to get this to work without explicitly requiring <code>ostruct</code> in my controller. 2) It also works without explicitly specifying <code>"object false"</code> in your .rabl file.</p>
<p><strong> </strong></p>
]]></content:encoded>
			<wfw:commentRss>http://bigtrapeze.com/2012/03/22/using-rabl-to-display-multiple-models/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding Gemfile Dependencies</title>
		<link>http://bigtrapeze.com/2012/01/24/understanding-gemfile-dependencies/</link>
		<comments>http://bigtrapeze.com/2012/01/24/understanding-gemfile-dependencies/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 00:36:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Learning Rails]]></category>
		<category><![CDATA[homepost]]></category>

		<guid isPermaLink="false">http://bigtrapeze.com/?p=160</guid>
		<description><![CDATA[I really struggled with this while learning Rails. In the Gemfile, I thought you could have groupings of Gems that would only be installed for a particular environment, like: group :production do gem 'execjs' gem 'mysql' end And, you can&#8211;but not in the way I thought. What I thought was that if my environment was [...]]]></description>
			<content:encoded><![CDATA[<p>I really struggled with this while learning Rails. In the Gemfile, I thought you could have groupings of Gems that would only be installed for a particular environment, like:</p>
<div class="wp_syntax">
<div class="code">
<pre class="rails" style="font-family:monospace;">group <span style="color:#ff3333; font-weight:bold;">:production</span> <span style="color:#9966CC; font-weight:bold;">do</span>
gem <span style="color:#996600;">'execjs'</span>
gem <span style="color:#996600;">'mysql'</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre>
</div>
</div>
<p>And, you can&#8211;but not in the way I thought. What I <em>thought</em> was that if my environment was set to something other than &#8220;<code>production</code>,&#8221; then those Gems wouldn&#8217;t load. But that&#8217;s not the case without a little extra coaxing from bundler.</p>
<p>To ignore those gems, when I bundle, I need to add the switch <code>--without production</code>, like</p>
<div class="wp_syntax">
<div class="code">
<pre class="rails" style="font-family:monospace;">bundle install <span style="color:#006600; font-weight:bold;">--</span>without production</pre>
</div>
</div>
<p>Obviously you&#8217;d want to change <em>production</em> to whatever group you wanted bundler to skip. Doing this stores a flag in your <code>APP_ROOT/.bundle/config</code> file, and then subsequent bundles won&#8217;t include gems within the production group. That&#8217;s how you get groupings of Gems to be ignored in your Gemfile. To read more, check out <a href="http://gembundler.com/rationale.html">http://gembundler.com/rationale.html</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigtrapeze.com/2012/01/24/understanding-gemfile-dependencies/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Easy inline if-then-else for Rails</title>
		<link>http://bigtrapeze.com/2012/01/20/easy-inline-if-then-else-for-rails/</link>
		<comments>http://bigtrapeze.com/2012/01/20/easy-inline-if-then-else-for-rails/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 15:08:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Learning Rails]]></category>

		<guid isPermaLink="false">http://bigtrapeze.com/?p=157</guid>
		<description><![CDATA[Instead of something bloated like: name = &#34;-&#34; unless User.name.nil? name = User.name end You can do it all in one quick line using Rails&#8217; rescue bailout name = User.name rescue &#34;-&#34; or, even better (thanks @buckdoyle) name = User.name &#124;&#124; &#34;-&#34;]]></description>
			<content:encoded><![CDATA[<p>Instead of something bloated like:</p>
<div class="wp_syntax">
<div class="code">
<pre class="rails" style="font-family:monospace;">name = <span style="color:#996600;">&quot;-&quot;</span>
<span style="color:#9966CC; font-weight:bold;">unless</span> User.<span style="color:#9900CC;">name</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>?
  name = User.<span style="color:#9900CC;">name</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre>
</div>
</div>
<p>You can do it all in one quick line using Rails&#8217; rescue bailout</p>
<div class="wp_syntax">
<div class="code">
<pre class="rails" style="font-family:monospace;">name = User.<span style="color:#9900CC;">name</span> <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#996600;">&quot;-&quot;</span></pre>
</div>
</div>
<p>or, even better (thanks @buckdoyle)</p>
<div class="wp_syntax">
<div class="code">
<pre class="rails" style="font-family:monospace;">name = User.<span style="color:#9900CC;">name</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#996600;">&quot;-&quot;</span></pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://bigtrapeze.com/2012/01/20/easy-inline-if-then-else-for-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Rails or Rails Gems without Ri and RDOC documentation</title>
		<link>http://bigtrapeze.com/2012/01/18/installing-rails-or-rails-gems-without-ri-and-rdoc-documentation/</link>
		<comments>http://bigtrapeze.com/2012/01/18/installing-rails-or-rails-gems-without-ri-and-rdoc-documentation/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 20:38:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Learning Rails]]></category>

		<guid isPermaLink="false">http://bigtrapeze.com/?p=154</guid>
		<description><![CDATA[use the &#8211;no-ri &#8211;no-rdoc switches, like rails install &#8211;no-ri &#8211;no-rdoc]]></description>
			<content:encoded><![CDATA[<p>use the &#8211;no-ri &#8211;no-rdoc switches, like</p>
<p>rails install &#8211;no-ri &#8211;no-rdoc</p>
]]></content:encoded>
			<wfw:commentRss>http://bigtrapeze.com/2012/01/18/installing-rails-or-rails-gems-without-ri-and-rdoc-documentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing the MySQL Gem in Lion</title>
		<link>http://bigtrapeze.com/2011/11/09/installing-the-mysql-gem-in-lion/</link>
		<comments>http://bigtrapeze.com/2011/11/09/installing-the-mysql-gem-in-lion/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 16:46:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Learning Rails]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[homepage]]></category>
		<category><![CDATA[homepost]]></category>

		<guid isPermaLink="false">http://bigtrapeze.com/?p=143</guid>
		<description><![CDATA[I kept getting weird permissions errors trying to install the MySQL gem for Ruby 1.9.2. The issue is that I was running the 64-bit version of Ruby with a 32-bit version of MySQL&#8211;which is the standard in new Lion installs. To fix, download the 64-bit version of MySQL from mysql.com, install, and then run: export [...]]]></description>
			<content:encoded><![CDATA[<p>I kept getting weird permissions errors trying to install the MySQL gem for Ruby 1.9.2. The issue is that I was running the 64-bit version of Ruby with a 32-bit version of MySQL&#8211;which is the standard in new Lion installs. To fix, download the 64-bit version of MySQL from mysql.com, install, and then run:</p>
<p><code>export ARCHFLAGS="-arch i386 -arch x86_64" ; gem install --no-rdoc --no-ri mysql -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/local/mysql/bin/mysql_config<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://bigtrapeze.com/2011/11/09/installing-the-mysql-gem-in-lion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

