<?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; ruby on rails</title>
	<atom:link href="http://mightyvites.com/blog/tag/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://mightyvites.com/blog</link>
	<description></description>
	<lastBuildDate>Tue, 21 May 2013 22:57:42 +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>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>sendgrid mailchimp rails</li><li>rails mailchimp tutorial</li><li>mailchimp rails</li><li>sendgrid mailchimp</li><li>mailchimp transactional emails</li><li>sendgrid email template with mail api</li><li>rails mail client</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>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>Baking ActiveRecord Cookies With JSON</title>
		<link>http://mightyvites.com/blog/web-tech/baking-activerecord-cookies-with-json/</link>
		<comments>http://mightyvites.com/blog/web-tech/baking-activerecord-cookies-with-json/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 15:00:33 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Web Tech]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.mighty-nice.com/?p=157</guid>
		<description><![CDATA[Our upcoming Mightyvites site has a nifty form where users can calculate the cost of their invitations. There are a number of options to choose from, and once a user makes the effort to price a package they shouldn&#8217;t lose their settings if they leave the page. It&#8217;s imperative that the form pick up where [...]]]></description>
				<content:encoded><![CDATA[<p>Our upcoming Mightyvites site has a nifty form where users can calculate the cost of their invitations. There are a number of options to choose from, and once a user makes the effort to price a package they shouldn&#8217;t lose their settings if they leave the page. It&#8217;s imperative that the form pick up where the user left off so that it is easy for them to continue with their purchase. That said I needed a way to persist their configuration, but I couldn&#8217;t rely on the database because the user very well may be anonymous. I also didn&#8217;t want to use the session because it will expire soon.<br />
<span id="more-157"></span><br />
<strong>Solution:</strong> a new cookie to store the user&#8217;s last set of form parameters.</p>
<p><strong>Hurdles:</strong></p>
<ul>
<li>I need a reliable way to serialize the data so I can store it as a string in the cookie</li>
<li>When I retrieve the cookie I need to deserialize the data and get it into an <code>ActiveRecord</code> object for form display</li>
</ul>
<p>This is easily done with Rails using <a href="http://www.json.org/" target="_blank">JSON</a> because</p>
<ol>
<li>Cookie management in Rails is dead simple</li>
<li>Rails extends Ruby&#8217;s <code>Object</code> class to include a <code>#to_json</code> method</li>
<li><code>ActiveSupport</code> provides easy JSON deserialization</li>
</ol>
<h2>Saving the POST in a cookie as JSON</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">cookies<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:last_order</span><span style="color:#006600; font-weight:bold;">&#93;</span>=<span style="color:#006600; font-weight:bold;">&#123;</span>
  <span style="color:#ff3333; font-weight:bold;">:expires</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">1</span>.<span style="color:#9900CC;">year</span>.<span style="color:#9900CC;">from_now</span>,
  <span style="color:#ff3333; font-weight:bold;">:value</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> params.<span style="color:#9900CC;">to_json</span><span style="color:#006600; font-weight:bold;">&#40;</span>
    <span style="color:#ff3333; font-weight:bold;">:except</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#996600;">'commit'</span>, <span style="color:#996600;">'authenticity_token'</span>, <span style="color:#996600;">'action'</span>, <span style="color:#996600;">'controller'</span> <span style="color:#006600; font-weight:bold;">&#93;</span>
  <span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></td></tr></table></div>

<p>When a request comes in I store the user&#8217;s order settings in a cookie named &#8216;last_order&#8217;. The cookie expires in 1 year. The value of the cookie is everything returned by <code>#params</code>, minus the stuff I don&#8217;t need, in JSON format. The <code>:except</code> filter given to <code>#to_json</code> ensures that I only save what is necessary for recalling the order and nothing more.</p>
<h2>Deserializing the cookie into an ActiveRecord</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> find_order
  serialized=cookies<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:last_order</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#9966CC; font-weight:bold;">if</span> serialized.<span style="color:#9900CC;">blank</span>?
&nbsp;
  last_order=<span style="color:#6666ff; font-weight:bold;">ActiveSupport::JSON</span>.<span style="color:#9900CC;">decode</span><span style="color:#006600; font-weight:bold;">&#40;</span>serialized<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#9966CC; font-weight:bold;">if</span> last_order.<span style="color:#9900CC;">blank</span>?
&nbsp;
  <span style="color:#0066ff; font-weight:bold;">@order</span>=Order.<span style="color:#9900CC;">new</span>
  <span style="color:#0066ff; font-weight:bold;">@order</span>.<span style="color:#9900CC;">attributes</span>=last_order
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>The method checks the request cookies for &#8216;last_order&#8217;. If found we use <code>ActiveSupport::JSON#decode</code> to deserialize the previous POST into a <code>Hash</code> object. If deserialization is successful, instantiate a new <code>ActiveRecord</code> and set its attributes to the parameters retrieved from the cookie. The <code>@order</code> variable is then used in the view with <code>form_for</code> to populate the form with the user&#8217;s last selections.</p>
<h2>Wrap Up</h2>
<p>This works well, and I actually got it working on the first try. I like the solution because JSON is a light-weight serialization format. You could do the same thing using <a href="http://en.wikipedia.org/wiki/Xml" target="_blank">XML</a> or <a href="http://www.yaml.org/" target="_blank">YAML</a> since Rails provides support for the former and Ruby support for the latter, but the output of both was more verbose than what I needed. Since I&#8217;m storing in a cookie space is a concern.</p>
<p>This example is based on Rails 2.2.2. The current <a href="http://api.rubyonrails.org/" target="_blank">Rails API </a>seems to be different, so your calls may vary, but the idea stays the same.</p>
<p>You&#8217;ll likely want to inspect your cookie. A good way to do that is with <a href="http://getfirebug.com/" target="_blank">Firebug</a>.</p>
<h4>Incoming search terms:</h4><ul><li>rails json cookie</li><li>rails json cookies</li><li>activerecord store json</li><li>rails json session</li><li>rails cookie json</li><li>mighty nice blog</li><li>json cookie</li><li>rails session json</li><li>json cookie rails</li><li>store json activerecord</li></ul>]]></content:encoded>
			<wfw:commentRss>http://mightyvites.com/blog/web-tech/baking-activerecord-cookies-with-json/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
