<?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>Mightyvites Blog &#187; Web Tech</title>
	<atom:link href="http://mightyvites.com/blog/category/web-tech/feed/" rel="self" type="application/rss+xml" />
	<link>http://mightyvites.com/blog</link>
	<description></description>
	<lastBuildDate>Thu, 09 May 2013 14:07:36 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Hybrid Invitations Powered By Rails 3.2 and Ruby 1.9.3</title>
		<link>http://mightyvites.com/blog/web-tech/hybrid-invitations-powered-by-rails-3-2-and-ruby-1-9-3/</link>
		<comments>http://mightyvites.com/blog/web-tech/hybrid-invitations-powered-by-rails-3-2-and-ruby-1-9-3/#comments</comments>
		<pubDate>Wed, 20 Jun 2012 18:43:40 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Web Tech]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://mightyvites.com/blog/?p=2717</guid>
		<description><![CDATA[Since the push to Rails 3.1.3 I&#8217;ve actually upgraded mightyvites.com to use Rails 3.2.3 and Ruby 1.9.3. This was an easy move forward with little to write home about. The upgrade was significant, however, because Ruby 1.9.3 is noticeably faster than 1.9.2 and Rails 3.2.3 has a much better development environment. It only reloads classes that [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright  wp-image-2718" title="ruby-1.9.3" src="http://mightyvites.com/wp-content/uploads/2012/06/ruby-1.9.3.jpg" alt="ruby 1.9.3" width="182" height="177" />Since <a title="Ruby On Rails 3.1: Upgrading To The Asset Pipeline" href="http://mightyvites.com/blog/web-tech/ruby-on-rails-3-1-upgrading-to-the-asset-pipeline/">the push to Rails 3.1.3</a> I&#8217;ve actually upgraded <a href="http://mightyvites.com/">mightyvites.com</a> to use Rails 3.2.3 and Ruby 1.9.3. This was an easy move forward with little to write home about. The upgrade was significant, however, because Ruby 1.9.3 is noticeably faster than 1.9.2 and Rails 3.2.3 has a much better development environment. It only reloads classes that have changed plus it has query explains. Check out <a href="http://guides.rubyonrails.org/3_2_release_notes.html%22">the release notes</a> to read about all the goodness. I certainly thought this upgrade was worth it.</p>
<p><span id="more-2717"></span></p>
<p>UPDATE: Since moving to 3.2.3 I&#8217;ve upgraded the site to 3.2.6. The minor update was <a href="http://weblog.rubyonrails.org/2012/6/12/ann-rails-3-2-6-has-been-released/" target="_blank">to address the recent security exploits found in Rails</a>. It was a simple change in gem versions to make this upgrade work.</p>
<h4>Incoming search terms:</h4><ul><li>wedding rsvp via email wording</li><li>how to word rsvp on wedding invitations</li><li>wedding png</li><li>1 mightyvites</li><li>rails invitations</li><li>rails3 rescue_action_in_public</li><li>powered by ruby on rails 3</li><li>rsvp plus one wedding</li><li>rsvp wedding cards with email</li><li>ruby</li></ul>]]></content:encoded>
			<wfw:commentRss>http://mightyvites.com/blog/web-tech/hybrid-invitations-powered-by-rails-3-2-and-ruby-1-9-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby On Rails 3.1: Upgrading To The Asset Pipeline</title>
		<link>http://mightyvites.com/blog/web-tech/ruby-on-rails-3-1-upgrading-to-the-asset-pipeline/</link>
		<comments>http://mightyvites.com/blog/web-tech/ruby-on-rails-3-1-upgrading-to-the-asset-pipeline/#comments</comments>
		<pubDate>Fri, 18 May 2012 00:03:50 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Web Tech]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://mightyvites.com/blog/?p=2668</guid>
		<description><![CDATA[Shortly after making the big leap from Rails 2.2.2 to 3.0.10 Rails 3.1 came out. Feeling defeated in my quest to have mightyvites.com on the latest stable release I started down the path of upgrading to 3.1.3. Replacing 3.0.10 with 3.1.3 was actually simple: just change the rails version in my Gemfile and &#8220;bundle update [...]]]></description>
				<content:encoded><![CDATA[<p><img src="http://mightyvites.com/wp-content/uploads/2012/05/rails3_asset_pipeline.jpg" alt="rails3 asset pipeline" title="rails3_asset_pipeline" width="250" height="250" class="alignright size-full wp-image-2695" style="margin: 1em 0 1em 1em;"/>Shortly after making <a title="Upgrade To Rails 3.0.10 And Ruby 1.9.2 Reviewed" href="http://mightyvites.com/blog/web-tech/upgrade-to-rails-3-0-10-and-ruby-1-9-2-reviewed/">the big leap from Rails 2.2.2 to 3.0.10</a> Rails 3.1 came out. Feeling defeated in my quest to have <a href="http://mightyvites.com">mightyvites.com</a> on the latest stable release I started down the path of upgrading to 3.1.3. Replacing 3.0.10 with 3.1.3 was actually simple: just change the rails version in my Gemfile and &#8220;bundle update rails&#8221;. After that it was trivial to get my tests running without error and essentially be upgraded.  However, that wasn&#8217;t the goal. Rails 3.1 is all about the asset pipeline and I wanted the concatenation, minification, and cache busting that it brings to the table.<br />
<span id="more-2668"></span></p>
<h2>What&#8217;s the asset pipeline?</h2>
<p>In a nutshell, the asset pipeline brings production-release processing of JavaScript, CSS stylesheets, and images to the Rails core. With the help of the <a href="https://github.com/lautis/uglifier" target="_blank">Uglifier</a> and <a href="https://github.com/sstephenson/sprockets" target="_blank">Sprockets</a> gems JS &amp; CSS are stripped of white space and comments, variable name simplified, and stitched together into one big download (one for JS, one for CSS). Asset files are named with a MD5 hash of the file to ensure that returning browsers download any new asset change.</p>
<h2>Benefits of using the asset pipeline</h2>
<p>So why do you want this feature? Because it optimizes your web app&#8217;s front end for delivering a rich client-side experience. By stripping away unnecessary bytes your assets become smaller and take less time to download. By concatenating all JavaScript in one big file and all CSS in another the browser only has two downloads to worry about and not many (same reason we use <a href="http://www.w3schools.com/css/css_image_sprites.asp" target="_blank">image sprites</a>). By naming files with a hash of their data file names are sure to change whenever the data changes, forcing revisiting browsers to download the change and not rely on an out-of-date cache.</p>
<h2>Working with the asset pipeline</h2>
<p>I&#8217;m not going to get into how to enable the asset pipeline on a Rails 3.1 app. There is <a href="http://guides.rubyonrails.org/asset_pipeline.html" target="_blank">a good Rails Guide</a> to help with that. Instead I want to talk about an issue that I ran into but couldn&#8217;t find documented anywhere: once I had the asset pipeline properly enabled my site looked, and behaved, like crap. Why? Because I liked to break my assets into multiple files. I actually had a home grown system that auto-included assets whose filenames were based on the name of the controller and action that served a request. This led to many asset files, each tailored to a specific page, and each included only on the page they were meant for. That common, &#8220;old school&#8221; approach did not work well out of the box with the new pipeline. Moving all existing assets into the app/assets directory and letting Sprockets compile them made all hell break loose because the result is that every page included all known JS &amp; CSS. There was no more page scoping. CSS cascades were ruined, and JS meant for one page reacted on different pages because the DOM was similar. The result was a total friggin&#8217; mess that I had to resolve without rewriting all my assets.</p>
<h3>Scoping CSS for inclusion on the asset pipeline</h3>
<p>Carefully crafted, browser tested CSS was by far my biggest concern. There was no way I was going to lose the hours that went into making it work. Luckily a new addition to the Rails 3.1 core helped tremendously: <a href="http://sass-lang.com/download.html" target="_blank">SASS</a> a.k.a. syntactically awesome stylesheets. The name says it all. SASS is everything us old time web devs have wanted CSS to be but that the W3C drags its feet on. For my task the biggest win provided by SASS was <a href="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#nested_rules" target="_blank">nested rules</a>. That let me turn CSS that looked like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">   <span style="color: #6666ff;">.featured</span> <span style="color: #00AA00;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
      <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-5.75em</span><span style="color: #00AA00;">;</span>              
      <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2em</span> <span style="color: #933;">.75em</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">.75em</span><span style="color: #00AA00;">;</span>      
   <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>into this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">   body<span style="color: #6666ff;">.home</span> <span style="color: #00AA00;">&#123;</span>
      &amp;<span style="color: #6666ff;">.index</span> <span style="color: #00AA00;">&#123;</span>
         <span style="color: #6666ff;">.featured</span> <span style="color: #00AA00;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
            <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-5.75em</span><span style="color: #00AA00;">;</span>              
            <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2em</span> <span style="color: #933;">.75em</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">.75em</span><span style="color: #00AA00;">;</span>      
         <span style="color: #00AA00;">&#125;</span>
      <span style="color: #00AA00;">&#125;</span>
   <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Remember, I was including my asset files based on the name of the controller and action that served a request. The asset pipeline made that impossible because all CSS is in one file. My solution was to continue scoping by controller and action name by including those names in the body element&#8217;s class attribute. I then used SASS&#8217; nested rules to wrap existing CSS in the new body classes. The result is what you see above &#8212; page scoped CSS that plays well in a single file.  </p>
<h3>Scoping JavaScript for inclusion on the asset pipeline</h3>
<p>Once I figured out how to handle my CSS, JavaScript was a cinch. I could use the same strategy with jQuery. So JS that looked like:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[type=submit]:first'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">effect</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pulsate'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span> times<span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Was turned into this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">   <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rsvps'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'update_notes'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[type=submit]:first'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">effect</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pulsate'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span> times<span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        ....
   <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Again, page scoped JavaScript that plays well in a single file. Moving forward I could use the same strategy with the JavaScript equivalent of SASS, <a href="http://coffeescript.org/" target="_blank">CoffeScript</a>, which was also brought into the Rails core with 3.1.</p>
<h2>Was it worth it?</h2>
<p>The upgrade to Rails 3.1.3 with full asset pipeline integration did take some time. An asset upgrade strategy needed to be figured out, changes needed to be made, and significant browser testing needed to be done. By the time I finished I was skeptical that the effort was worth it, but once I released to production I was pleasantly surprised to see that it was. Pages loaded significantly faster than they used to. I was using minification before the upgrade, but the Sprockets concatenation gave a big boost. I could actually feel the difference. Best of all I now have a nice stage set for building out <a href="http://mightyvites.com">mightyvites.com</a> with heavy dependence on client-side processing.</p>
<h4>Incoming search terms:</h4><ul><li>path to asset pipeline images</li><li>ruby on rails asset pipeline</li><li>asset pipeline upgrade</li><li>asset pipeline</li><li>ruby assets with hash names</li><li>ruby asset pipeline sub web</li><li>rails3 qrcode</li><li>rails scoping css</li><li>rails pipeline ensure loaded only once</li><li>rails migrate to asset pipeline</li></ul>]]></content:encoded>
			<wfw:commentRss>http://mightyvites.com/blog/web-tech/ruby-on-rails-3-1-upgrading-to-the-asset-pipeline/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Nginx Maintenance Configuration That Works</title>
		<link>http://mightyvites.com/blog/web-tech/a-nginx-maintenance-configuration-that-works/</link>
		<comments>http://mightyvites.com/blog/web-tech/a-nginx-maintenance-configuration-that-works/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 21:34:59 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Web Tech]]></category>

		<guid isPermaLink="false">http://mightyvites.com/blog/?p=2507</guid>
		<description><![CDATA[We use the lightening fast Nginx web server to handle our mightyvites.com requests. Like most sites we need to go offline once in awhile to deploy new code, address server issues, etc. When we take the main site down we start a single-page website that gives the obligatory &#8220;down for maintenance&#8221; message. Recently I updated the configuration file for [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-2517" title="nginx_maintenance" src="http://mightyvites.com/wp-content/uploads/2012/01/nginx_maintenance.jpeg" alt="nginx maintenance" width="200" height="103" />We use the lightening fast <a href="http://nginx.org/" target="_blank">Nginx</a> web server to handle our <a href="http://mightyvites.com">mightyvites.com</a> requests. Like most sites we need to go offline once in awhile to deploy new code, address server issues, etc. When we take the main site down we start a single-page website that gives the obligatory &#8220;down for maintenance&#8221; message. Recently I updated the configuration file for this maintenance site so that it worked properly. By properly I mean all incoming requests get the maintenance page and are returned a HTTP 503 &#8220;Service Unavailable.&#8221;</p>
<p><span id="more-2507"></span>Simple enough, right? A pretty common need. I thought it would be easy to find an example online that I could use. Turns out there are tons of examples, but few work! It took me awhile but I eventually cobbled together a useable config.</p>
<pre>server {
  listen 80;
  server_name localhost;
  root /var/www/maintenance;</pre>
<pre>  error_page 503 /index.html;</pre>
<pre>  location /index.html {
    # show page
  }</pre>
<pre>  location / {
    return 503;
  }
}</pre>
<p>Dead simple once you get it. Every incoming request is served index.html (the maintenance page) and receives a 503 status code. This works with Nginx 0.7.65.</p>
<h4>Incoming search terms:</h4><ul><li>nginx maintenance page</li><li>nginx maintenance</li><li>nginx down for maintenance</li><li>nginx maintenance message</li><li>maintenance page nginx</li><li>nginx offline page</li><li>maintenance nginx</li><li>nginx maintenance config</li><li>nginx maintainance page</li><li>nginx get Status Code</li></ul>]]></content:encoded>
			<wfw:commentRss>http://mightyvites.com/blog/web-tech/a-nginx-maintenance-configuration-that-works/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrade To Rails 3.0.10 And Ruby 1.9.2 Reviewed</title>
		<link>http://mightyvites.com/blog/web-tech/upgrade-to-rails-3-0-10-and-ruby-1-9-2-reviewed/</link>
		<comments>http://mightyvites.com/blog/web-tech/upgrade-to-rails-3-0-10-and-ruby-1-9-2-reviewed/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 15:15:12 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Web Tech]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://mightyvites.com/blog/?p=2457</guid>
		<description><![CDATA[Over a year ago (!) I announced my intention to upgrade mightyvites.com from Ruby 1.8.7 and Rails 2.2.2 to Ruby 1.9.2 and Rails 3. Took me long enough but I&#8217;m now finally following up on the issue. No, it didn&#8217;t take me a year to do the upgrade. Shortly after I wrote that post I took a full time Rails [...]]]></description>
				<content:encoded><![CDATA[<p><img class="size-full wp-image-2476 alignleft" title="ruby_on_rails_3_upgrade" src="http://mightyvites.com/wp-content/uploads/2012/01/ruby_on_rails_3_upgrade.jpeg" alt="ruby on rails 3 upgrade" width="204" height="204" />Over a year ago (!) <a title="The Mighty Nice March To Ruby On Rails 3 And Ruby 1.9.2" href="http://mightyvites.com/blog/web-tech/the-mighty-nice-march-to-ruby-on-rails-3-and-ruby-1-9-2/">I announced my intention to upgrade mightyvites.com from Ruby 1.8.7 and Rails 2.2.2 to Ruby 1.9.2 and Rails 3</a>. Took me long enough but I&#8217;m now finally following up on the issue.</p>
<p>No, it didn&#8217;t take me a year to do the upgrade. Shortly after I wrote that post I took a full time Rails job. Then my business got busy with paying customers. Then <a href="http://mightyvites.com/blog/category/one-mans-wedding/">I got engaged and a few months later married</a>. There were a lot of distractions which kept throwing me off my Ruby On Rails upgrade plans. I did do it though. In fact I completed two Rails upgrades this summer. One for <a href="http://mightyvites.com">mightyvites.com</a> and one for my employer. In both cases I transitioned webapps from Rails 2.x to Rails 3.0.10 and introduced Ruby 1.9.2. Doing so was definitely worth it. Rails 3 feels so much more mature than previous releases. The upgrade, however, was not easy. Below are the issues I had to deal with to make it happen.<br />
<span id="more-2457"></span></p>
<h2>Changes in Rails</h2>
<ul>
<li>The Rails.root/lib directory must be autoloaded</li>
<li>My use of JRails could be dropped due to the new UJS approach of JavaScript handling</li>
<li>#fields_for and #form_for require &lt;%= ERB blocks</li>
<li>@controller was deprecated for #controller</li>
<li>ApplicationController#filter_parameter_logging is now config.filter_parameters in application.rb</li>
<li>Must mark application HTML as html_safe due to XSS protection being the default</li>
<li>No more CGI::Session::CookieStore::TamperedWithCookie (because of signed cookies?)</li>
<li>#rescue_action_in_public usage changed to #rescue_from (really a Rails 2.3 change)</li>
<li>Awful &#8220;You have a model in a subdirectory, where the name of the subdirectory matches the name of the model.&#8221; problem (<a href="http://www.williambharding.com/blog/technology/rails-3-autoload-modules-and-classes-in-production" target="_blank">succinct explanation (point 4)</a>, <a href="http://owenou.com/2011/01/20/loading-path-gotchas-in-rails3.html" target="_blank">technical explanation</a>)</li>
<li>Terrible &#8220;incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) (Encoding::CompatibilityError)&#8221; problem caused by rendering XLS file with render :file =&gt;. Fixed by using #send_file</li>
<li>ActiveRecord attributes with errors are displayed in a form_for with CSS class &#8216;field_with_errors&#8217; as opposed to the preveious &#8216;fieldWithErrors&#8217;</li>
<li>Had to uncomment the Nginx version of config.action_dispatch.x_sendfile_header in production.rb</li>
</ul>
<h2>Changes in Ruby gems</h2>
<ul>
<li><a href="https://github.com/mislav/will_paginate" target="_blank">will_paginate</a> needs 3.0.pre2</li>
<li><a href="https://github.com/brianmario/mysql2" target="_blank">mysql2</a> needs 0.2.11</li>
<li>had to <a href="http://tlug.dnho.net/node/276" target="_blank">encode DB to UTF8</a>. Apparently mysql gem would change encoding to UTF8 while mysql2 gem does not?</li>
<li><a href="https://github.com/terra-firma/hominid" target="_blank">hominid</a> needs 2.1.9</li>
<li><a href="https://github.com/rmagick/rmagick" target="_blank">rmagick</a> required building ImageMagick via MacPorts w/o openmp support (<a href="http://stackoverflow.com/questions/2838307/why-is-this-rmagick-call-generating-a-segmentation-fault/3638135#3638135" target="_blank">CaptainPete&#8217;s explanation</a>)</li>
</ul>
<h2>Changes in Ruby</h2>
<ul>
<li>Array#choice now #sample</li>
<li>YAML lib changes to Psych; can no longer handle ypaths with #select</li>
<li>Drop use of FasterCSV because it is now the native CSV</li>
</ul>
<p>&nbsp;</p>
<p>I would say the average time it took for me to do each upgrade was 3 weeks. A full test suite was invaluable in tracking the state of the upgrade, and after launch I inevitably found bits of un-html_safe&#8217;d output. I released the Rails 3 upgrade of <a href="http://mightyvites.com">mightyvites.com</a> in September of &#8217;11. Since then I&#8217;ve upgraded the site to Rails 3.1 and instituted <a href="http://guides.rubyonrails.org/asset_pipeline.html" target="_blank">the new asset pipeline</a>. Hopefully I&#8217;ll write about that sooner rather than later.</p>
<h4>Incoming search terms:</h4><ul><li>rails 3 rescue_action_in_public</li><li>rescue_action_in_public rails 3</li><li>upgrade to rails 3 0 10</li><li>update to rails 3 0 10</li><li>rails 3 0 10 changes</li><li>upgrade rails 2 to 3</li><li>send_data rails 3 0 10</li><li>rails rescue_action_in_public</li><li>ruby 3 0 10</li><li>rescue_action_in_public rails3</li></ul>]]></content:encoded>
			<wfw:commentRss>http://mightyvites.com/blog/web-tech/upgrade-to-rails-3-0-10-and-ruby-1-9-2-reviewed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby On Rails Transactional Email Using MailChimp And SendGrid</title>
		<link>http://mightyvites.com/blog/web-tech/ruby-on-rails-transactional-email-using-mailchimp-and-sendgrid/</link>
		<comments>http://mightyvites.com/blog/web-tech/ruby-on-rails-transactional-email-using-mailchimp-and-sendgrid/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 16:17:34 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Web Tech]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://mightyvites.com/blog/?p=2374</guid>
		<description><![CDATA[Since launch mightyvites.com has sent email through Gmail using very basic HTML/ERB templates. There have been no graphics, little styling, and zero email client testing. In other words our emails have sucked and looked very unprofessional. Why? Because those are the last things you worry about when you&#8217;re trying to push out the door a product that you&#8217;re not sure anyone will [...]]]></description>
				<content:encoded><![CDATA[<p><img src="http://mightyvites.com/wp-content/uploads/2011/12/mailchimp_sendgrid.jpg" alt="mailchimp sendgrid" title="mailchimp_sendgrid" width="303" height="130" class="alignright size-full wp-image-2420" />Since launch <a href="http://mightyvites.com/">mightyvites.com</a> has sent email through <a href="http://gmail.com" target="_blank">Gmail</a> using very basic HTML/ERB templates. There have been no graphics, little styling, and zero email client testing. In other words our emails have sucked and looked very unprofessional. Why? Because those are the last things you worry about when you&#8217;re trying to push out the door a product that you&#8217;re not sure anyone will buy. Once your site has users, however, these are the bells and whistles you need to put time into.</p>
<p>Recently the time came for me to spruce up the emails <a href="http://mightyvites.com/">mightyvites.com</a> sends. I wanted slick-looking HTML that looks good in all email clients, makes it to users&#8217; inboxes, is multipart, and can be tracked. In addition the email templates should be easy for non-geeks to edit. That way they can be changed often and not always by me.<br />
<span id="more-2374"></span><br />
I&#8217;m a fan of <a href="http://mailchimp.com" target="_blank">MailChimp</a>. We use <a href="http://apidocs.mailchimp.com/api/1.3/" target="_blank">their (robust) API</a> to programmatically manage our newsletter subscriber list. They make it very easy to compose, send, and track well-designed HTML email. They do not, however, make it easy to send transactional email. That&#8217;s not their niche so they don&#8217;t cater to it <sup class='footnote'><a href='#fn-2374-1' id='fnref-2374-1' onclick='return fdfootnote_show(2374)'>1</a></sup>. <a href="http://blog.mailchimp.com/transactional-email-support/" target="_blank">There is a work around</a>, but it leaves much to be desired. MailChimp transactional emails must include unsubscribe links and other <a href="http://en.wikipedia.org/wiki/CAN-SPAM_Act_of_2003" target="_blank">CAN-SPAM compliance</a> content which is just out of place on notices like forgotten password emails. The MailChimp email composer, however, is pretty sweet. It&#8217;s easy to use and generates cross-client compatible HTML email complete with text versions for multi-part. The composer was perfect for my needs, but sending through MailChimp was no good because doing so automatically adds the unwanted mailing list links. Then it hit me: if I could compose and save my emails in MailChimp and later export them I could include the export in my Rails app and send through the email provider of my choice. Possible? With <a href="https://github.com/terra-firma/hominid" target="_blank">hominid, the MailChimp API Ruby gem</a>, yes.</p>
<p>Hominid wraps the well documented MailChimp API for use in Ruby applications. It adds the syntactic sugar most Rubyists would expect and pretty much does a 1 to 1 mapping of the methods MailChimp defines. Part of the API deals with what MailChimp calls templates. Templates are reusable emails that you create at <a href="http://mailchimp.com/" target="_blank">mailchimp.com</a> and save to your account. You can access these HTML templates through the API and run them through a method to generate a text version. With both a HTML and text version &#8220;in hand&#8221; you can write the output to disk and have what you need for ActionMailer to generate fancy, multi-part emails that were edited online with MailChimp&#8217;s slick editor. I keep all this action in a Rake task which I run every time I update a template at MailChimp.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">  desc <span style="color:#996600;">&quot;Task to pull customer email templates from MailChimp and cache them in the app&quot;</span>
  task <span style="color:#ff3333; font-weight:bold;">:import_email_templates</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:environment</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#008000; font-style:italic;"># Maintain a map of ActionMailer methods to MailChimp</span>
    <span style="color:#008000; font-style:italic;"># template names in a YAML file. YAML looks like:</span>
    <span style="color:#008000; font-style:italic;"># &lt;mailer class name&gt;:</span>
    <span style="color:#008000; font-style:italic;">#   &lt;mailer method name&gt;: &lt;name of MailChimp template used by method&gt;</span>
    <span style="color:#008000; font-style:italic;"># Example:</span>
    <span style="color:#008000; font-style:italic;"># user_mailer:</span>
    <span style="color:#008000; font-style:italic;">#   signed_up: &quot;Welcome To Mightyvites&quot;</span>
    <span style="color:#008000; font-style:italic;">#   ...</span>
    map=<span style="color:#CC00FF; font-weight:bold;">YAML</span>.<span style="color:#9900CC;">load_file</span><span style="color:#006600; font-weight:bold;">&#40;</span>MAILER_TEMPLATE_YAML<span style="color:#006600; font-weight:bold;">&#41;</span>
    api=<span style="color:#6666ff; font-weight:bold;">Hominid::API</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>MAILCHIMP_API_KEY<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># loop through the list of known MailChimp template names</span>
    api.<span style="color:#9900CC;">templates</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'user'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>template<span style="color:#006600; font-weight:bold;">|</span>
      html_cache=<span style="color:#0000FF; font-weight:bold;">nil</span>
&nbsp;
      <span style="color:#008000; font-style:italic;"># find the mailer class and method this template belongs to</span>
      map.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>mailer, emails<span style="color:#006600; font-weight:bold;">|</span>
        template_name=emails.<span style="color:#9900CC;">invert</span><span style="color:#006600; font-weight:bold;">&#91;</span>template<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'name'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
        <span style="color:#9966CC; font-weight:bold;">if</span> template_name
          html_cache=<span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>Rails.<span style="color:#9900CC;">application</span>.<span style="color:#9900CC;">config</span>.<span style="color:#9900CC;">view_path</span>, mailer.<span style="color:#9900CC;">to_s</span>, <span style="color:#996600;">&quot;#{template_name}.html.erb&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
          <span style="color:#9966CC; font-weight:bold;">break</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
      <span style="color:#9966CC; font-weight:bold;">next</span> <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exist</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>html_cache<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
      <span style="color:#008000; font-style:italic;"># pull the latest HTML templates from MailChimp</span>
      html=api.<span style="color:#9900CC;">template_info</span><span style="color:#006600; font-weight:bold;">&#40;</span>template<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'id'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_i</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'source'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
      <span style="color:#008000; font-style:italic;"># create a text version of the HTML for multi-part mail</span>
      text=api.<span style="color:#9900CC;">generate_text</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'html'</span>, html<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
      <span style="color:#008000; font-style:italic;"># inline all CSS to ensure greatest email client compatibility</span>
      html=api.<span style="color:#9900CC;">inline_css</span><span style="color:#006600; font-weight:bold;">&#40;</span>html<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
      <span style="color:#008000; font-style:italic;"># overwrite mailer views</span>
      <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>html_cache, <span style="color:#996600;">'w+'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> f <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> html <span style="color:#006600; font-weight:bold;">&#125;</span>
      text_cache=html_cache.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'.html.erb'</span>, <span style="color:#996600;">'.text.erb'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>text_cache, <span style="color:#996600;">'w+'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> f <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> text <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></pre></td></tr></table></div>

<p>With that code I can easily update my application&#8217;s mail templates and manage them at MailChimp. My templates don&#8217;t change often so I keep the update manual, but you could set up a cron job to pull in changes nightly, or create a Capistrano task to pull in a fresh copy with each application deployment. </p>
<p>So what about tracking? That was the last wish on my list and was easily gotten with a nifty SMTP service called <a href="http://sendgrid.com" target="_blank">SendGrid</a>. Goodbye Gmail! SendGrid works extra hard to give my application a high email delivery rate and it provides a nice web interface for viewing all email sends, clicks, bounces, etc. SendGrid&#8217;s tracking isn&#8217;t as slick as MailChimp&#8217;s, but it&#8217;s a heck of a lot better than nothing. Overall I&#8217;ve been very pleased with SendGrid&#8217;s service, and happy as a clam with my MailChimp&#8217;d ActionMailer templates.</p>
<div class='footnotes' id='footnotes-2374'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-2374-1'>In response to Amazon&#8217;s recent foray into transactional email <a href="http://blog.mailchimp.com/mailchimp-launches-transactional-email-service-on-top-of-amazon-ses/" target="_blank">MailChimp created a service on top of SES</a>. <span class='footnotereverse'><a href='#fnref-2374-1'>&#8617;</a></span></li>
</ol>
</div>
<h4>Incoming search terms:</h4><ul><li>sendgrid templates</li><li>sendgrid email templates</li><li>rails transactional email</li><li>rails mailchimp tutorial</li><li>mailchimp rails</li><li>sendgrid mailchimp rails</li><li>tracking emails sent through rails application using mailchimp</li><li>sendgrid email template with mail api</li><li>rails mail client</li><li>sendgrid mailchimp</li></ul>]]></content:encoded>
			<wfw:commentRss>http://mightyvites.com/blog/web-tech/ruby-on-rails-transactional-email-using-mailchimp-and-sendgrid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu Upstart Gotcha When Monitoring MySQL With God</title>
		<link>http://mightyvites.com/blog/web-tech/ubuntu-upstart-gotcha-when-monitoring-mysql-with-god/</link>
		<comments>http://mightyvites.com/blog/web-tech/ubuntu-upstart-gotcha-when-monitoring-mysql-with-god/#comments</comments>
		<pubDate>Thu, 23 Dec 2010 00:40:01 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Web Tech]]></category>

		<guid isPermaLink="false">http://mightyvites.com/blog/?p=1051</guid>
		<description><![CDATA[I recently upgraded our two Slicehost VPSs from Ubuntu Hardy Heron (8.04) to Lucid Lynx (10.04). That&#8217;s from one LTS to another, and the process, overall, went very smoothly. To pull it off I followed the 8.04 to 10.04 instructions on the Slicehost Wiki. There were, however, two gotchas that I came across during the upgrade process. [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1069" title="Upstart Gotcha!" src="http://mightyvites.com/wp-content/uploads/2010/12/gotcha.jpg" alt="Ubuntu Upstart Gotcha When Monitoring MySQL With God" width="225" height="225" />I recently upgraded our two <a href="http://slicehost.com" target="_blank">Slicehost</a> VPSs from <a href="https://help.ubuntu.com/8.04/serverguide/C/index.html" target="_blank">Ubuntu Hardy Heron (8.04)</a> to <a href="https://help.ubuntu.com/10.04/serverguide/C/index.html" target="_blank">Lucid Lynx (10.04)</a>. That&#8217;s from one <a href="https://wiki.ubuntu.com/LTS" target="_blank">LTS</a> to another, and the process, overall, went very smoothly. To pull it off I followed the <a href="http://wiki.slicehost.com/doku.php?id=upgrade_ubuntu-server_lts_to_lts" target="_blank">8.04 to 10.04 instructions on the Slicehost Wiki</a>. There were, however, two gotchas that I came across during the upgrade process.<br />
<span id="more-1051"></span><br />
For one, I needed to have the highest version kernel available installed on my VPS before starting the upgrade. <a href="http://wiki.slicehost.com/doku.php?id=upgrade_ubuntu-server_lts_to_lts" target="_blank">The docs</a> say &#8220;Make Sure Kernel 2.6.32 or Newer is Installed&#8221;, but that&#8217;s not high enough. I checked that condition before the upgrade, and met it, but after the upgrade when my slice rebooted it failed to come up. In a panic I emailed Slicehost support and they quickly got back to me saying &#8220;upgrade to the highest kernel version available&#8221;, which happened to be 2.6.35.4-rscloud. I did that, then my slice booted properly.</p>
<p>The bigger gotcha was with my server monitoring. I use <a href="http://god.rubyforge.org/" target="_blank">god</a> to monitor my web serving stack. That means god watches over <a href="http://www.mysql.com/" target="_blank">MySQL</a>. Ubuntu used to run the MySQL server with the tried and true <code>/sbin/init</code> which, when spawning the MySQL daemon, created a file <code>/var/run/mysqld/mysqld.pid</code> that contained the process id of the daemon. God relies upon that .pid file to detect whether or not the server is running. If the .pid file is missing, or the PID in the file doesn&#8217;t match the id in the process list that god knows about, it thinks the server is down and will start yelling at you via whatever notifications you have configured. Recent versions of Ubuntu use <a href="http://upstart.ubuntu.com/" target="_blank">upstart</a> to control the MySQL server. Upstart doesn&#8217;t create the .pid files that god needs for monitoring. That put a glitch in my setup.</p>
<p>I began searching for answers in god&#8217;s documentation and discovered that you can watch non-daemon processes (i.e. those that don&#8217;t create a .pid file) with god. To do so just don&#8217;t specify a <code>pid_file</code> in your god watch. In that case god will create  pid for you in <code>/var/run/god</code> and use it for monitoring. Simple enough, but no dice. For whatever reason that didn&#8217;t work for me. God would create <code>/var/run/god/mysql.pid</code> but still complain that the server is down. More searching led me to <a href="http://flowcoder.com/170" target="_blank">a Flowcoder post</a> that provides a way to create a .pid file from an upstart script for server monitoring. The post is for a couchdb-lucene server, but the code was easily adapted for MySQL. I made it work by editing <code>/etc/init/mysql.conf</code>. Here are the important parts:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">post-start script
    <span style="color: #666666; font-style: italic;"># Make a .pid file for god monitoring of MySQL</span>
    <span style="color: #007800;">PID</span>=<span style="color: #000000; font-weight: bold;">`</span>status mysql <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #660033;">-oi</span> <span style="color: #ff0000;">'([0-9]+)$'</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">head</span> -n1<span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$PID</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>mysqld<span style="color: #000000; font-weight: bold;">/</span>mysqld.pid
    ....
end script
&nbsp;
post-stop script
   <span style="color: #666666; font-style: italic;"># Remove the .pid file used for god monitoring of MySQL</span>
   <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>mysqld<span style="color: #000000; font-weight: bold;">/</span>mysqld.pid
end script</pre></td></tr></table></div>

<p>Voila! Now I can control the MySQL server via <code>/usr/sbin/service</code> and it will create and clean up <code>/var/run/mysqld/mysqld.pid</code> for me. Most important, god gets its .pid file and monitors happily. That&#8217;s all good, but I don&#8217;t like the fact that I had to edit a /etc/init file to do this. Anyone got a better solution?</p>
<p><em><a href="http://mighty-nice.com">Mighty Nice</a> proudly serves its web content using Linux and other open source technologies</em></p>
<h4>Incoming search terms:</h4><ul><li>upstart pid file</li><li>god upstart</li><li>ubuntu mysql pid</li><li>upstart pid</li><li>ubuntu mysql pid file</li><li>upstart god</li><li>upstart pidfile</li><li>upstart pid files</li><li>ubuntu mysqld pid</li><li>mysql pid ubuntu</li></ul>]]></content:encoded>
			<wfw:commentRss>http://mightyvites.com/blog/web-tech/ubuntu-upstart-gotcha-when-monitoring-mysql-with-god/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Mighty Nice March To Ruby On Rails 3 And Ruby 1.9.2</title>
		<link>http://mightyvites.com/blog/web-tech/the-mighty-nice-march-to-ruby-on-rails-3-and-ruby-1-9-2/</link>
		<comments>http://mightyvites.com/blog/web-tech/the-mighty-nice-march-to-ruby-on-rails-3-and-ruby-1-9-2/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 15:00:38 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Web Tech]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.mighty-nice.com/?p=901</guid>
		<description><![CDATA[I&#8217;ve been working with Ruby On Rails 2.2.2 and Ruby 1.8.7 for a little over a year now. The Mightyvites site is built on that foundation, as is the Mighty Nice site, and a few of our client sites. However, with the release of Rails 3, and it&#8217;s compatibility with Ruby 1.9.2, I&#8217;m itching to [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright" title="Ruby On Rails 3" src="http://mightyvites.com/wp-content/uploads/2010/11/rails3.png" alt="Ruby On Rails 3" width="87" height="111" /></p>
<p>I&#8217;ve been working with <a href="http://rubyonrails.org/" target="_blank">Ruby On Rails</a> 2.2.2 and <a href="http://www.ruby-lang.org/en/" target="_blank">Ruby</a> 1.8.7 for a little over a year now. The <a href="http://mightyvites.com">Mightyvites</a> site is built on that foundation, as is the <a href="http://mighty-nice.com">Mighty Nice</a> site, and a few of our client sites. However, with the <a href="http://edgeguides.rubyonrails.org/3_0_release_notes.html" target="_blank">release of Rails 3</a>, and it&#8217;s compatibility with Ruby 1.9.2, I&#8217;m itching to upgrade both. There are a few reasons why I want to upgrade the cores of our RoR sites:<span id="more-901"></span></p>
<ul>
<li>I don&#8217;t like to fall behind in upgrades. If you skip too many stable releases of a critical software package you&#8217;ll run into big headaches when you do decide to upgrade.</li>
<li>It&#8217;s a good excuse to upgrade everything our sites run on: gems, plugins, JavaScript libraries, etc. Just do a full upgrade release and get it over with.</li>
<li>I want core support of <a href="http://rails-engines.org/" target="_blank">Rails Engines</a>. Currently I use Rails Engines as a plugin. The less plugins to manage the better.</li>
<li>I want to drop use of the <a href="http://mirror.ozdiy.com/assets/b8/2f96a12bc919b37e09d303b86ea1b9_1251811910.html" target="_blank">Jrails</a> plugin and harness <a href="http://www.simonecarletti.com/blog/2010/06/unobtrusive-javascript-in-rails-3/" target="_blank">unobtrusive JavaScript</a></li>
<li>I want the bug fixes and performance improvements. I have no complaints with Ruby/Rails performance, but I would like to use <a href="http://en.wikipedia.org/wiki/YARV" target="_blank">the new Ruby interpreter</a> which is supposedly 15% faster than the old (but slower than the previous interpreter with ActiveRecord? Yikes!).</li>
<li>Rails routes have <a href="http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/" target="_blank">a new sugary syntax</a> (er. <a href="http://www.infoq.com/news/2007/06/dsl-or-not" target="_blank">DSL</a>) which will help clean up my routes.rb files.</li>
<li><a href="http://mightyvites.com/blog/2010/11/12/mighty-nice-lessons-from-chicago-ruby-hack-night/">Ruby has some cool new features</a></li>
</ul>
<p>That&#8217;s more than enough reasons to upgrade, and thankfully I&#8217;ve got the time to do it now. In preparation I&#8217;ve cut a new development branch and I&#8217;ve talked to some fellow Chicago Rubyists to get their take on the upgrade process. One fella I met at last month&#8217;s <a href="http://www.meetup.com/Software-Craftsman-Chicago/" target="_blank">software craftsman meetup</a> pointed me to the <a href="https://github.com/rails/rails_upgrade" target="_blank">rails_upgrade plugin</a>, which I&#8217;ve already tried out and am impressed with. The plugin takes the pain out of the upgrade guess process by running through your code and printing out all you need to change and why. That&#8217;s super handy, and should help cut down significantly on the brute force break/fix upgrade cycle. There is also a good lookin&#8217; <a href="http://www.railsupgradehandbook.com/" target="_blank">PDF</a> written on the upgrade process.</p>
<p>One thing to note: a few people have told me that moving to Rails 3 isn&#8217;t bad, but moving to Ruby 1.9 is not as easy. The reason being that many gems and plugins aren&#8217;t yet compatible. I&#8217;m going to give the move to Ruby 1.9 a try, but we&#8217;ll see how far I get.</p>
<h4>Incoming search terms:</h4><ul><li>rails 3 slower than rails 2</li><li>Mighty Rails</li><li>rails 3 ruby 1 9 performance</li><li>rails3 ruby 1 9 performance</li><li>rails3 slower</li><li>rails3 slower than rails2</li><li>ruby 1 9 2 performance</li><li>invitation plugin in ruby on rails 3</li><li>ruby on rails 3</li><li>upgrade rails 3 to 1 9 2</li></ul>]]></content:encoded>
			<wfw:commentRss>http://mightyvites.com/blog/web-tech/the-mighty-nice-march-to-ruby-on-rails-3-and-ruby-1-9-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mighty Nice Lessons From ChicagoRuby Hack Night</title>
		<link>http://mightyvites.com/blog/web-tech/mighty-nice-lessons-from-chicago-ruby-hack-night/</link>
		<comments>http://mightyvites.com/blog/web-tech/mighty-nice-lessons-from-chicago-ruby-hack-night/#comments</comments>
		<pubDate>Fri, 12 Nov 2010 19:57:18 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Web Tech]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.mighty-nice.com/?p=913</guid>
		<description><![CDATA[Last night I attended a ChicagoRuby Hack Night. It was my first one, and well worth going to. The topic was Ruby 1.9 and how it differs from 1.8. The format was very casual. There was a written introduction to 1.9, and attendees randomly paired up to explore the intro on their laptop&#8217;s irb command [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-917" title="ruby 1.9" src="http://mightyvites.com/wp-content/uploads/2010/11/ruby1.png" alt="Ruby 1.9" width="100" height="100" />Last night I attended a <a href="http://www.meetup.com/ChicagoRuby/" target="_blank">ChicagoRuby</a> Hack Night. It was my first one, and well worth going to. The topic was <a href="http://www.ruby-lang.org/en/" target="_blank">Ruby</a> 1.9 and how it differs from 1.8. The format was very casual. There was <a href="http://files.meetup.com/288361/ruby192.txt" target="_blank">a written introduction to 1.9</a>, and attendees randomly paired up to explore the intro on their laptop&#8217;s irb command line. It was a good opportunity to meet like-minded people and geek out on some cool new language features. Here&#8217;s what I learned about Ruby 1.9 at the ChicagoRuby Hack Night:<br />
<span id="more-913"></span></p>
<ul>
<li>Varargs can now appear anywhere in a method definition</li>
<li>Block parameters are now like method parameters: they can have default args and varargs</li>
<li>Since symbols-as-keys hashes are so common in Ruby there is now a concise way of writing it. <code>{ :a =&gt; 1, :b =&gt; 2}</code> can now just be <code>{ a: 1, b: 2 }</code> (hash literals).</li>
<li>Hashes now retain creation order. I&#8217;m mixed on this. A classic hash algorithm won&#8217;t maintain order for the sake of speed. If you want order, use an array. I feel like Ruby is blurring the lines here, much like it does with the distinction between arrays and linked lists in the Array class. However, hashes are used so frequently in Ruby that this is a welcomed feature.</li>
<li>The Fiber library introduces a lighter-than-light-weight-threads way of doing concurrency. Granted you have to schedule the concurrency yourself, so you better know what you&#8217;re doing, but in simple cases this can be an improvement over firing off Threads.</li>
<li>The CSV library is now FasterCSV. I currently use FasterCSV as a gem. The less gems I have to worry about the better.</li>
</ul>
<p>Cool stuff, and I&#8217;m excited to use it in production. Now I just need to upgrade!</p>
<p>By the way, since I haven&#8217;t upgraded my system Ruby yet I played with 1.9 via the <a href="http://rvm.beginrescueend.com/" target="_blank">Ruby Version Manager (RVM)</a>, an easy to use command line tool that allows you to keep different versions of Ruby on your box and switch between them with ease. It works great!</p>
<p><em><a href="http://mighty-nice.com">Mighty Nice</a> <a href="http://mightyvites.com">Mightyvites</a> are proudly powered by Ruby and <a href="http://rubyonrails.org" target="_blank">Ruby On Rails</a></em></p>
<h4>Incoming search terms:</h4><ul><li>chicago ruby hack night</li><li>night vites</li><li>command line ruby hack</li><li>how to use command prompt to hack</li><li>lessons of how to use command prompt to hack</li><li>nice lessons</li><li>nite vites re</li><li>owd hacknight blog</li><li>ruby varargs hash</li></ul>]]></content:encoded>
			<wfw:commentRss>http://mightyvites.com/blog/web-tech/mighty-nice-lessons-from-chicago-ruby-hack-night/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Few Days With Google Chrome</title>
		<link>http://mightyvites.com/blog/web-tech/a-few-days-with-google-chrome/</link>
		<comments>http://mightyvites.com/blog/web-tech/a-few-days-with-google-chrome/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 16:10:06 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Web Tech]]></category>

		<guid isPermaLink="false">http://blog.mighty-nice.com/?p=249</guid>
		<description><![CDATA[Recently more than one web developing friend told me that they had switched from Firefox to Google Chrome for their everyday browsing and work needs. That&#8217;s saying a lot because Firefox has some great development add-ons, and because web devs know their browsers. I was curious, and since I was recently into analyzing my browser, [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-314" style="border:0 initial initial;" title="Google Chrome" src="http://mightyvites.com/wp-content/uploads/2010/06/chrome_icon.jpg" alt="Google Chrome" width="164" height="164" /></p>
<p>Recently more than one web developing friend told me that they  had switched from Firefox to <a href="http://www.google.com/chrome" target="_blank">Google Chrome</a> for their everyday browsing  and work needs. That&#8217;s saying a lot because Firefox has some  great development add-ons, and because web devs know their browsers. I was  curious, and since I was <a href="http://mightyvites.com/blog/2010/04/25/fixing-firefox-3-6/">recently into analyzing my browser</a>, I thought I&#8217;d  give Chrome on OS X a shot.<br />
<span id="more-249"></span><br />
Google Chrome is the result of the open source project <a href="http://www.chromium.org/Home" target="_blank">Chromium</a>. It&#8217;s the first <a href="http://www.chromium.org/developers/design-documents/multi-process-architecture" target="_blank">multi-threaded browser</a> and, being the  new kid on the browser block, it has been able to capitalize on the experience of its competition. That last point shows in the Chrome&#8217;s slick interface and usability. Here is what I noticed shortly after install:</p>
<ul>
<li>It starts fast. Click the Chrome icon and boom, it opens.</li>
<li>It renders fast. Pages come up lightning quick just like in Safari and other webkit browsers.</li>
<li>The &#8220;new tab&#8221; page nicely lays out your bookmarks toolbar,  thumbnails of recently browsed locations, a list of recently closed  tabs, and easy access to full history.</li>
<li>Address bar is also your search bar. This is similar to Firefox&#8217;s  &#8220;Awesome Bar&#8221; but instead gives you search results.</li>
<li>New tabs tear out AND can be pushed back in.</li>
<li>Downloads, plugins, and history are easily managed through pages  rendered in the browser. This just makes sense.</li>
<li>&#8220;View source&#8221; opens in a new tab and has line numbers.</li>
<li>Same webkit development tools that you find in Safari.</li>
<li>Nice task manager for viewing Chrome&#8217;s, and other browsers&#8217;, memory usage</li>
<li>Each tab runs in its own thread. When you close a tab the thread  dies and its resources are freed up. If a page in a tab misbehaves the  tab may die but the whole browser won&#8217;t crash.</li>
</ul>
<p>Because of Chrome&#8217;s multi-threaded nature it  is <a href="http://blog.chromium.org/2008/09/google-chrome-memory-usage-good-and-bad.html" target="_blank">difficult to get an accurate measurement</a> of  how much RAM the whole browser is really using. However, casual profiling using <a href="http://support.apple.com/kb/HT1342" target="_blank">OS X&#8217;s Activity Monitor</a>, and Chrome&#8217;s monitoring tools (In Chrome: View -&gt; Developer -&gt; Task Manager -&gt; Stats for nerds), suggests to me that Chrome uses about the same amount of RAM as <a href="http://mightyvites.com/blog/2010/04/25/fixing-firefox-3-6/">a tweaked-out Firefox</a> (300-350MB). Maybe a little more. And that&#8217;s with just a few tabs of plain ol&#8217; web pages open. No Flash and no audio streaming. Throw either of those in the mix, and/or open a lot (10+) tabs, and memory usage spikes fast leading to poor performance.</p>
<p>So there are some memory issues with Chrome. Under light usage it acts mature and stable, but once you pile on tasks the browser loses its footing. Since I run a lot of big apps simultaneously everyday, a browser always one of them, memory is precious to me. Those issues alone are enough to keep me away from using Chrome full-time. Other no-go factors include the not so-smooth-transition from page to page and the fact that Chrome still has a small user base. As a web developer I need to build my sites in a browser that most people use, and on a Mac that means Firefox.</p>
<p><a href="http://www.w3schools.com/browsers/browsers_stats.asp" target="_blank">Chrome usage is rising fast</a>. In time I&#8217;m sure all if its current downsides will disappear. Google will fix its memory problems and page transitions because users will complain of side-effects. Average users will adopt Chrome and web devs will become comfortable using it full-time. Until that happens, however, Chrome will be just one more browser that I need to test our sites with.</p>
<h4>Incoming search terms:</h4><ul><li>google chrome icon</li><li>chrome icon</li><li>chrome</li><li>chrome icon jpg</li><li>chrome page transitions</li><li>google crome multithread</li><li>chrome google icon</li><li>icon google chrome</li><li>icon chrome</li><li>mightychrome google</li></ul>]]></content:encoded>
			<wfw:commentRss>http://mightyvites.com/blog/web-tech/a-few-days-with-google-chrome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing Firefox 3.6</title>
		<link>http://mightyvites.com/blog/web-tech/fixing-firefox-3-6/</link>
		<comments>http://mightyvites.com/blog/web-tech/fixing-firefox-3-6/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 20:20:30 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Web Tech]]></category>

		<guid isPermaLink="false">http://blog.mighty-nice.com/?p=221</guid>
		<description><![CDATA[Recently I became very frustrated with my long time browser of choice: Firefox. Version 3.6.3 on OS X Snow Leopard became the biggest memory hog on my system. After leaving the browser open for a while my MacBook would start to grind to a halt. I&#8217;d check the Activity Monitor and see that Firefox was [...]]]></description>
				<content:encoded><![CDATA[<p>Recently I became very frustrated with my long time browser of choice: <a href="http://www.mozilla.com/en-US/firefox/personal.html?from=getfirefox" target="_blank">Firefox</a>. Version 3.6.3 on OS X Snow Leopard became the biggest memory hog on my system. After leaving the browser open for a while my MacBook would start to grind to a halt. I&#8217;d <a href="http://support.apple.com/kb/HT1342" target="_blank">check the Activity Monitor</a> and see that Firefox was consuming anywhere from 500MB to 1GB of my 4GB of RAM. That was much more than any other application running at the time. Performance was dismal. I needed a fix.</p>
<p>Searching for a fix led me to a post titled <a href="http://blog.codefront.net/2008/09/10/optimize-firefoxs-memory-usage-by-tweaking-session-preferences/" target="_blank"><em>Optimize Firefox&#8217;s memory usage by tweaking session preferences</em></a>. I followed the author&#8217;s suggestions point by point and then rebooted my box to get a clean slate. After monitoring Firefox&#8217;s memory usage for a few days I was thrilled to see that it consistently only consumed 300-350MB of RAM. That&#8217;s a huge performance boost for a few simple tweaks.</p>
<p>Too bad those options are hidden in &#8216;about:config&#8217;. Hey Firefox devs, how about some performance options in the preferences pane?</p>
<h4>Incoming search terms:</h4><ul><li>fixing firefox</li></ul>]]></content:encoded>
			<wfw:commentRss>http://mightyvites.com/blog/web-tech/fixing-firefox-3-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
