<?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>redemption in a blog &#187; General</title>
	<atom:link href="http://blog.codefront.net/category/general/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.codefront.net</link>
	<description>Rails, Firefox, Anime, Mac</description>
	<lastBuildDate>Mon, 14 Jun 2010 03:22:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Dragging tab to a new window coming to Firefox</title>
		<link>http://blog.codefront.net/2008/11/16/dragging-tab-to-a-new-window-coming-to-firefox/</link>
		<comments>http://blog.codefront.net/2008/11/16/dragging-tab-to-a-new-window-coming-to-firefox/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 14:15:05 +0000</pubDate>
		<dc:creator>Chu Yeow</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.codefront.net/?p=1132</guid>
		<description><![CDATA[Completely by accident, I discovered that you can now drag a tab out from its current window to a new window in a recent Firefox nightly. A short video 24-second better explains what I&#8217;m talking about: This tab tearing capability is a pretty neat feature &#8211; I know you can already do this in Safari, [...]]]></description>
			<content:encoded><![CDATA[<p>Completely by accident, I discovered that you can now drag a tab out from its current window to a new window in a recent Firefox nightly. A short video 24-second better explains what I&#8217;m talking about:</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/yecyFamSh6c&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/yecyFamSh6c&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>This tab tearing capability is a pretty neat feature &#8211; I know you can already do this in Safari, Opera and Galeon. It&#8217;s really well done in Safari, which I think is what Firefox is emulating. Nice to see Firefox follow suit!</p>
<p>If you can&#8217;t wait for Firefox 3.1, try it out in a recent <a href="http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/">Firefox nighty build</a> (remember to <a href="http://support.mozilla.com/en-US/kb/Managing+profiles">use a new profile</a> unless you are willing to risk corrupting your daily profile).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codefront.net/2008/11/16/dragging-tab-to-a-new-window-coming-to-firefox/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Optimize Firefox&#8217;s memory usage by tweaking session preferences</title>
		<link>http://blog.codefront.net/2008/09/10/optimize-firefoxs-memory-usage-by-tweaking-session-preferences/</link>
		<comments>http://blog.codefront.net/2008/09/10/optimize-firefoxs-memory-usage-by-tweaking-session-preferences/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 12:57:24 +0000</pubDate>
		<dc:creator>Chu Yeow</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.codefront.net/?p=1130</guid>
		<description><![CDATA[I&#8217;m a heavy tabbed browsing user &#8211; I have around 30 tabs open in my day-to-day Firefox profile all the time. Since the day Firefox 3 was released, I&#8217;ve noticed Firefox progressively getting slower with this particular Firefox profile (I use a different profile for web development). When it got to the point where changing [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a heavy tabbed browsing user &#8211; I have around 30 tabs open in my day-to-day Firefox profile all the time. Since the day Firefox 3 was released, I&#8217;ve noticed Firefox progressively getting slower with this particular Firefox profile (I use a different profile for web development). When it got to the point where changing tabs took a noticeable pause of 1-2 seconds, I tweaked some of Firefox&#8217;s session store and history preferences and now things are blazing fast again.</p>
<p>Here&#8217;s what you can do:</p>
<ol>
<li>Go to <a href="about:config">about:config</a> in Firefox.</li>
<li>Type in &#8220;session&#8221; in the &#8220;Filter&#8221; box.</li>
<li>Edit <strong>browser.sessionhistory.max_entries</strong> &#8211; this is the number of pages stored in the history of your browsing session. Basically these are pages that can be reached using your Back and Forward buttons. The default is 50 &#8211; I reduced it to 20.</li>
<li>Edit <strong>browser.sessionhistory.max_total_viewers</strong> &#8211; this is the number of pages that are stored in RAM so that they aren&#8217;t re-processed by Firefox&#8217;s rendering engine. This is what allows you to go Back to a page in Firefox and have it load almost instantaneously. The number of pages stored actually depends on the amount of RAM on your machine (<a href="http://kb.mozillazine.org/Browser.sessionhistory.max_total_viewers">see this</a>). I reduced this to 4 (I have 2GB RAM).</li>
<li>Edit <strong><a href="http://kb.mozillazine.org/Browser.sessionstore.max_tabs_undo">browser.sessionstore.max_tabs_undo</a></strong> &#8211; the number of tabs you can restore after closing them (you can do this with Ctrl/Cmd-Shift-T). The default of 10 is more than I really need, so I reduced it to 3 tabs.</li>
<li>Edit <strong><a href="http://kb.mozillazine.org/Browser.sessionstore.interval">browser.sessionstore.interval</a></strong> &#8211; Firefox saves your session after every 10 seconds by default. I changed this to a more conservative 30000 milliseconds.</li>
</ol>
<p>You can <a href="http://kb.mozillazine.org/About:config_entries">read more about these preferences and more at the MozillaZine Knowledge Base</a>. If you&#8217;ve any tips on how to improve Firefox&#8217;s performance, be sure to share!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codefront.net/2008/09/10/optimize-firefoxs-memory-usage-by-tweaking-session-preferences/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Sass with Rails &#8211; avoiding disappearing stylesheets in production</title>
		<link>http://blog.codefront.net/2008/08/07/sass-with-rails-avoiding-disappearing-stylesheets-in-production/</link>
		<comments>http://blog.codefront.net/2008/08/07/sass-with-rails-avoiding-disappearing-stylesheets-in-production/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 13:57:33 +0000</pubDate>
		<dc:creator>Chu Yeow</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.codefront.net/?p=1128</guid>
		<description><![CDATA[A few days ago I noticed that some of the pages on the Hotels app on wego.com were completely unstyled. They turned out looking rather Jakob Nielsen-istic: But we were attached to our ugly shade of green to leave those pages in their naked glory. Preliminary CSI work told me that some cached stylesheets generated [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago I noticed that some of the pages on the <a href="http://wego.com/hotels/">Hotels app on wego.com</a> were completely unstyled. They turned out looking rather <a href="http://www.useit.com/">Jakob Nielsen-istic</a>:</p>
<div class="img"><img src="http://blog.codefront.net/wp-content/uploads/2008/08/wegocom-hotels-no-css.png" alt="Wego.com Hotels - no CSS" /></div>
<p><br style="clear: both;" /></p>
<p>But we were attached to our ugly shade of green to leave those pages in their naked glory. Preliminary CSI work told me that <em>some</em> cached stylesheets generated by Rails were empty files. Why is this is happening?</p>
<h3>stylesheet_link_tag and the :cache option</h3>
<p>Was I overriding the stylesheets generated by Rails in different pages? Because we have a lot of cobranded sites and country sites on wego.com, I use the <code>:cache</code> option when using <code>stylesheet_link_tag</code> very often.</p>
<p>For example, the main wego.com site&#8217;s layout template has a <code>stylesheet_link_tag</code> like this (in reality there are a whole lot more stylesheets):</p>
<pre><code class="ruby">&lt;%= stylesheet_link_tag 'yui/reset-fonts', 'search',  :cache =&gt; 'cache/search/listings' %&gt;</code></pre>
<p>When I need to make a new page for a cobranded site, I&#8217;ll create a new layout template with this:</p>
<pre><code class="ruby">&lt;%= stylesheet_link_tag 'yui/reset-fonts', 'search', "sites/#{current_site}/cobrand", :cache => "cache/#{current_site}/search/listings" %&gt;</code></pre>
<p>Oftentimes I&#8217;d copy and paste (boo and hiss all you want!) the <code>stylesheet_link_tag</code> from one layout template to another and forget to update the cache path (the <code>:cache => '/path/to/stylesheet'</code> part). Two different stylesheet sets being cached to the same path is naturally a very stupid thing to do. So this wasn&#8217;t it, but it&#8217;s good to point this out because I have made this mistake at least 2 times!</p>
<h3>Don&#8217;t check in generated CSS files by accident</h3>
<p>Next, since I was using <a href="http://haml.hamptoncatlin.com/docs/rdoc/classes/Sass.html">Sass</a>, I was by now pretty sure that was it. First things first: did I check in a generated CSS file into source control (we use Git)? It&#8217;s another amateur mistake, but unsurprisingly, I&#8217;ve done this a couple of times. I think I&#8217;d wasted about an hour hunting down the reason for a style change that just wouldn&#8217;t show up. Yeah, I could have just added <code>*.css</code> to <code>.gitignore</code>, but I&#8217;m still using a mix of pure CSS and Sass templates.</p>
<h3>The problem</h3>
<p>In the end, I found this <a href="http://blog.citrusbyte.com/2008/3/20/sass-production-woes-rails/">blog post</a> by Ari Lerner on the <a href="http://blog.citrusbyte.com/">CitrusByte blog</a> about similar woes with Sass in production that set me on the path to a solution. It seems that when Rails encounters <code>stylesheet_link_tag</code> calls, it starts to pull together all the stylesheets and sometimes Sass is unable to generate the CSS files fast enough. Rails then throws an exception about not being able to find the CSS files and outputs an <strong>empty</strong> CSS file to the cache path.</p>
<h3>The solution</h3>
<p>The solution? Generate all the CSS files from Sass templates prior to restarting Rails when deploying. I added a rake task for updating all the Sass stylesheets:</p>
<pre><code class="ruby">namespace :sass do
  desc 'Updates stylesheets if necessary from their Sass templates.'
  task :update =&gt; :environment do
    Sass::Plugin.update_stylesheets
  end
end</code></pre>
<p>Then, I created a mirror of this as a Capistrano task:</p>
<pre><code class="ruby">namespace :sass do
  desc 'Updates the stylesheets generated by Sass'
  task :update, :roles =&gt; :app do
    invoke_command "cd #{latest_release}; RAILS_ENV=#{rails_env} rake sass:update"
  end

  # Generate all the stylesheets manually (from their Sass templates) before each restart.
  before 'deploy:restart', 'sass:update'
end</code></pre>
<p>Now, whenever I do a <code>cap deploy</code>, the stylesheets are generated before the Rails processes are restarted, ensuring that Rails&#8217; <code>stylesheet_link_tag</code> helper is always able to find the pure CSS files when trying to merge them together and caching them to a single file.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codefront.net/2008/08/07/sass-with-rails-avoiding-disappearing-stylesheets-in-production/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Living on the edge (of Rails) #20 &#8211; script/dbconsole and flash.now now test-able</title>
		<link>http://blog.codefront.net/2008/05/11/living-on-the-edge-of-rails-20-scriptdbconsole-and-flashnow-now-test-able/</link>
		<comments>http://blog.codefront.net/2008/05/11/living-on-the-edge-of-rails-20-scriptdbconsole-and-flashnow-now-test-able/#comments</comments>
		<pubDate>Sun, 11 May 2008 06:54:32 +0000</pubDate>
		<dc:creator>Chu Yeow</dc:creator>
				<category><![CDATA[Edge Rails]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.codefront.net/?p=1106</guid>
		<description><![CDATA[This week’s report covers changes from 5th May 2008 to 11th May 2008 (the day the corresponding Rails Envy podcast was recorded). script/dbconsole A script/dbconsole script has been added that allows you to connect to your database using its console client. If you needed to connect to your production MySQL database (you better know what [...]]]></description>
			<content:encoded><![CDATA[<p>This week’s report covers changes from 5th May 2008 to 11th May 2008 (the day the corresponding <a href="http://railsenvy.com/podcast/">Rails Envy podcast</a> was recorded).</p>
<h3>script/dbconsole</h3>
<p>A <code>script/dbconsole</code> script has been added that allows you to connect to your database using its console client.</p>
<p>If you needed to connect to your production MySQL database (you better know what you are doing!), for example, you can run <code>RAILS_ENV=production script/dbconsole</code> or simply <code>script/dbconsole production</code> (thanks to <a href="http://railscasts.com/">Ryan Bates</a> for pointing this out!) and it will login to your database server using the command line MySQL client. This also works with the PostgreSQL and SQLite databases.</p>
<p>To use this script in your Rails app, remember to run <code>rake rails:update:scripts</code> after updating to edge Rails.</p>
<p>This nice little enhancement courtesy of <a href="http://www.sanityinc.com/">Steve Purcell</a>, who originally had a similar <a href="http://www.sanityinc.com/articles/rails-db-console">database console plugin</a>.</p>
<p>Related changeset: <a href="http://github.com/rails/rails/commit/4a07103687084496b773e18a03b1f2f5e686f7ad">http://github.com/rails/rails/commit/4a07103687084496b773e18a03b1f2f5e686f7ad</a></p>
<h3>flash.now is now accessible in tests</h3>
<p>This is something that <a href="http://www.pluitsolutions.com/2008/01/22/testing-flashnow-in-rails/">many</a> <a href="http://rhnh.net/2008/04/19/testing-flash-now-with-rspec">of us</a> Rails developers have probably come across when writing tests for flash messages being set with <code>flash.now</code>, <a href="http://blog.codefront.net/2006/09/03/some-functional-testing-gotchas-in-ruby-on-rails/">myself included</a>. Basically, you couldn&#8217;t test the contents of your <code>flash.now</code> because they were always being emptied before your test could get to them.</p>
<pre><code class="ruby"># In your controller:
flash.now[:notice] = 'You gotta be kidding me!'

# In your test:
assert_equal 'You gotta be kidding me!', flash.now[:notice]
# FAILS because flash.now[:notice] is nil</code></pre>
<p><a href="http://zargony.com/">Andreas Neuhaus</a> took a good look at how it works and figured out how to make testing <code>flash.now</code> work without resorting to <code>assert_select</code>s.</p>
<p>Related changeset: <code>http://github.com/rails/rails/commit/74eed6290e63111d1aad2b181692a84f4f040aea</code></p>
<p>There isn&#8217;t much else of note so far but if you&#8217;d like to know every gritty detail, you&#8217;d probably want to peruse the <a href="http://github.com/rails/rails/commits/master">Rails commit logs</a>. As always, let me know of any suggestions or how I can improve the Living on the Edge (of Rails) series.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codefront.net/2008/05/11/living-on-the-edge-of-rails-20-scriptdbconsole-and-flashnow-now-test-able/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Announcing Wego.com &#8211; our travel meta-search engine in beta (Ruby included)</title>
		<link>http://blog.codefront.net/2008/05/01/announcing-wegocom-our-travel-meta-search-engine-in-beta-ruby-included/</link>
		<comments>http://blog.codefront.net/2008/05/01/announcing-wegocom-our-travel-meta-search-engine-in-beta-ruby-included/#comments</comments>
		<pubDate>Thu, 01 May 2008 05:33:26 +0000</pubDate>
		<dc:creator>Chu Yeow</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.codefront.net/?p=1104</guid>
		<description><![CDATA[So we&#8217;ve been terribly busy at Bezurk these last 2 months or so working on our new re-branded site with a bunch of new features. We were lucky enough to secure a 4-letter domain name &#8211; wego.com (and it came at a price too!) so it was all worth it. Trust me, with a name [...]]]></description>
			<content:encoded><![CDATA[<p>So we&#8217;ve been terribly busy at <a href="http://bezurk.com/">Bezurk</a> these last 2 months or so working on our new re-branded site with a bunch of new features. We were lucky enough to secure a 4-letter domain name &#8211; <a href="http://www.wego.com/">wego.com</a> (and it came at a price too!) so it was all worth it. Trust me, with a name like Bezurk you&#8217;re going to be terribly hard to remember and to brand. We&#8217;ve had partners and friends who spell Bezurk in a variety of ways: berserk, bezerk, buzerk. Don&#8217;t even ask us about our encounters with non-native English speakers. Don&#8217;t.</p>
<p>So yes, the new site: <a href="http://www.wego.com/">http://www.wego.com/</a>.</p>
<div class="img"><img src="http://www.wego.com/hotels/images/wego/home/wg_logo_beta.gif" alt="Wego.com logo" /></div>
<p><br style="clear: both;" /></p>
<p>We&#8217;ve decided to push it &#8220;live&#8221; as a beta product (and we know it is very much in beta, we&#8217;re not kidding or trying to be Web 2.0-ish) prior to our launch party next week. Give it a few hits or so and let me know of any feedback (leaving a comment here is good), <em>especially</em> what <em>annoys</em> you. You might even want to use it to search for <a href="http://www.wego.com/flights/">airline tickets</a> or to <a href="http://www.wego.com/hotels/">book hotel rooms</a> for your next trip and <a href="http://www.wego.com/feedback/">let us know</a> if we managed to somehow <em>epic fail</em> at the task. If you liked it or booked a trip somewhere, we&#8217;re glad to have helped you on your way.</p>
<p>I&#8217;d write more about wego.com but what I really wanted to focus on, being a Rubyist and all, is what is really cool to <em>me</em> about wego.com &#8211; we&#8217;ve rebuilt our <a href="http://www.wego.com/hotels/">Hotels product</a> from the ground up (it was a mostly Java before, and it is still live on <a href="http://bezurk.com/hotels/">http://bezurk.com/hotels/</a>) in 85% Ruby, 8% JavaScript, 5% Erlang, and 2% Java. Well, those are rough figures anyway. We also made a strong effort to keep our mostly AJAX application as usable as possible <em>without</em> JavaScript but I&#8217;ll admit, we had to cut some corners due to deadlines.</p>
<p>I&#8217;d love to be more specific about the design and architecture of our Hotels application and on the cool stuff (CouchDB, Rack, Solr, jQuery, libmemcached, and of course, Ruby) we&#8217;ve used that have made our lives as developers <em>much easier</em> than when we were in Javaland &#8211; but I&#8217;d leave that for a later post. I&#8217;m sure my friend <a href="http://arunthampi.wordpress.com/">Arun Thampi</a> also has a war story to tell so we&#8217;ll come up with something entertaining. Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codefront.net/2008/05/01/announcing-wegocom-our-travel-meta-search-engine-in-beta-ruby-included/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Declarative exception-handling in your controllers  &#8211; Rails 2.0 a feature a day #2</title>
		<link>http://blog.codefront.net/2007/12/10/declarative-exception-handling-in-your-controllers-rails-20-a-feature-a-day-2/</link>
		<comments>http://blog.codefront.net/2007/12/10/declarative-exception-handling-in-your-controllers-rails-20-a-feature-a-day-2/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 15:58:01 +0000</pubDate>
		<dc:creator>Chu Yeow</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.codefront.net/2007/12/10/declarative-exception-handling-in-your-controllers-rails-20-a-feature-a-day-2/</guid>
		<description><![CDATA[I know I said I was going to try and keep the features in &#8220;a feature a day&#8221; to those not mentioned in popular places, but this feature is one of the few nicest features in Rails made by a contributor outside of the Rails core so I couldn&#8217;t resist mentioning it. First, an example [...]]]></description>
			<content:encoded><![CDATA[<p>I know I <a href="http://blog.codefront.net/2007/12/09/rails-20-a-feature-a-day/">said</a> I was going to try and keep the features in <a href="http://blog.codefront.net/2007/12/09/rails-20-a-feature-a-day/">&#8220;a feature a day&#8221;</a> to those not mentioned in <a href="http://weblog.rubyonrails.org/2007/12/7/rails-2-0-it-s-done">popular</a> <a href="http://ryandaigle.com/">places</a>, but this feature is one of the few nicest features in Rails made by a contributor outside of the Rails core so I couldn&#8217;t resist mentioning it.</p>
<h3>First, an example</h3>
<pre><code class="ruby">class CommentsController &lt; ActionController::Base
  rescue_from Comment::Spammy, :with =&gt; :moderate_comment
  rescue_from ActiveRecord::RecordNotFound, :with =&gt; :redirect_if_not_found

  protected
    def moderate_comment
      # Handle the exception, like placing the comment in a moderation queue
      # and then rendering a different action.
    end

    def redirect_if_not_found
      # Redirect somewhere...
    end
end</code></pre>
<p>Compare this to what you had to do with Rails 1.2.6 and earlier:</p>
<pre><code class="ruby">class CommentsController &lt; ActionController::Base

  def rescue_action_in_public(exception)
    case exception
      when Comment::Spammy
        # Handle the exception as above.
      when ActiveRecord::RecordNotFound
        # Redirect somewhere...
      else
        super
    end
  end
end</code></pre>
<p>Much clearer and reads almost like English. I don&#8217;t think I even need to explain what the code in the 1st example is trying to do.</p>
<h3>Let&#8217;s try another example</h3>
<p>Here&#8217;s another common use-case: dealing bad create/update actions. With <code>rescue_from</code>, you can simply do this:</p>
<pre><code class="ruby">class ApplicationController &lt; ActionController::Base
  rescue_from ActiveRecord::RecordInvalid do |exception|
    render :action => (exception.record.new_record? ? :new : :edit)
  end
end</code></pre>
<p>No need for actions to be coded like this anymore!</p>
<pre><code class="ruby">def create
  @comment = comment.create!(params[:comment])
rescue ActiveRecord::RecordInvalid
  render :action => :new
end</code></pre>
<p>This patch was committed in <a href="http://dev.rubyonrails.org/changeset/7597">revision 7597</a> after a short discussion on the syntax and implementation over at the <a href="http://dev.rubyonrails.org/ticket/9449">ticket</a>. (More improvements on the implementation over at <a href="http://dev.rubyonrails.org/ticket/9645">ticket #9645</a> for the interested.)</p>
<h3>About the contributor, Norbert Crombach</h3>
<p><a href="http://primetheory.org/">Norbert Crombach</a> (Rails Trac username: <em>norbert</em>, <a href="http://www.workingwithrails.com/person/7507-norbert-crombach">WorkingWithRails profile</a>) is another <a href="http://dev.rubyonrails.org/query?reporter=norbert">regular Rails contributor</a> hailing from the Netherlands. The <code>rescue_from</code> is, in my opinion, one of his more significant contributions (and what a great one it is too).</p>
<h3>Some final words</h3>
<p>While the new declarative <code>rescue_from</code> macro is useful, I&#8217;ve found myself liking the <a href="http://merbivore.com/">merb</a> way of dealing with exceptions, where <a href="http://merbivore.com/features.html#exceptions">exception handling is delegated to an Exception controller</a>. You can use layouts, templates, helpers and filters just like in <em>ye plain olde</em> controller. I&#8217;m still not so sure if it&#8217;s worth making a patch for Rails to emulate this behavior yet though!</p>
<p><ins>Update: Rails 2.0 a feature a day #3 is now available <a href="http://blog.codefront.net/2007/12/12/concatenate-your-stylesheets-and-javascripts-in-3-seconds-rails-20-a-feature-a-day-3/">Concatenate your stylesheets and JavaScripts in 3 seconds</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codefront.net/2007/12/10/declarative-exception-handling-in-your-controllers-rails-20-a-feature-a-day-2/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Time#advance now uses :weeks, :hours, :minutes, :seconds options &#8211; Rails 2.0 a feature a day #1</title>
		<link>http://blog.codefront.net/2007/12/09/timeadvance-now-uses-weeks-hours-minutes-seconds-options-rails-20-a-feature-a-day-1/</link>
		<comments>http://blog.codefront.net/2007/12/09/timeadvance-now-uses-weeks-hours-minutes-seconds-options-rails-20-a-feature-a-day-1/#comments</comments>
		<pubDate>Sun, 09 Dec 2007 15:51:02 +0000</pubDate>
		<dc:creator>Chu Yeow</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.codefront.net/2007/12/09/timeadvance-now-uses-weeks-hours-minutes-seconds-options-rails-20-a-feature-a-day-1/</guid>
		<description><![CDATA[Time#advance and DateTime#advance just got, erm, more betterer in Rails 2.0. In Rails 1.2.6 and earlier, Time#advance and DateTime#advance only accepted :year, :month and :day options. You&#8217;d think :hours, :minutes and :seconds would work too but due to a bug in the code (see ticket #9818), you get something like this instead: time = Time.utc(2000,10,1,10,30,45) [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Time/Calculations.html#M000567"><code>Time#advance</code></a> and <a href="http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/DateTime/Calculations.html#M000714"><code>DateTime#advance</code></a> just got, erm, more betterer in Rails 2.0.</p>
<p>In Rails 1.2.6 and earlier, <code>Time#advance</code> and <code>DateTime#advance</code> only accepted <code>:year</code>, <code>:month</code> and <code>:day</code> options. You&#8217;d think <code>:hours</code>, <code>:minutes</code> and <code>:seconds</code> would work too but due to a bug in the code (see <a href="http://dev.rubyonrails.org/ticket/9818">ticket #9818</a>), you get something like this instead:</p>
<pre><code class="ruby">time = Time.utc(2000,10,1,10,30,45)
# => Sun Oct 01 10:30:45 UTC 2000

time.advance(:days =>3, :hour => 2)
# => Wed Oct 04 02:00:00 UTC 2000
</code></pre>
<p>Notice how the hour is changed instead of being advanced.</p>
<p>Now, thanks to <a href="http://mad.ly/">Geoff Buesing</a>&#8216;s <a href="http://dev.rubyonrails.org/ticket/9825">efforts</a>, passing <code>:hours</code>, <code>:minutes</code> and <code>:seconds</code> options work as you&#8217;d expect:</p>
<pre><code class="ruby">time = Time.local(2005,2,28,15,15,10)
# => Mon Feb 28 15:15:10 0800 2005

time.advance(:hours => 5, :minutes => 20, :seconds => 25)
# => Mon Feb 28 20:35:35 0800 2005</code></pre>
<p>Hell, you can even <code>#advance</code> by <code>:weeks</code> (see <a href="http://dev.rubyonrails.org/ticket/9866">ticket #9866</a>):</p>
<pre><code class="ruby">time = Time.local(2005,2,28,15,15,10)
# => Mon Feb 28 15:15:10 0800 2005

time.advance(:weeks => 2)
# => Mon Mar 14 15:15:10 0800 2005</code></pre>
<p>+1 for consistency and properly behaving code. Thanks to this #advance patch, Geoff was also able to re-use #advance to <a href="http://dev.rubyonrails.org/ticket/9863">refactor</a> some other parts of ActiveSupport&#8217;s time-related extensions.</p>
<h3>About the contributor, Geoff Buesing</h3>
<p><a href="http://mad.ly/">Geoff Buesing</a> is a regular Rails contributor and I&#8217;ve known him to be the date/datetime/time guru &#8211; just look at his <a href="http://dev.rubyonrails.org/query?reporter=%7Egbuesing&#038;order=priority">submitted patches</a> if you&#8217;re not convinced. Not too long ago Geoff was given well-deserved commit rights (congrats Geoff)! You won&#8217;t find him on the <a href="http://rubyonrails.org/core">Ruby on Rails Core team page</a> yet though &#8211; it&#8217;s probably out of date.</p>
<p>Check out his blog at <a href="http://mad.ly/">mad.ly</a> where he writes mostly his adventures with on unobtrusive JavaScript in Rails.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codefront.net/2007/12/09/timeadvance-now-uses-weeks-hours-minutes-seconds-options-rails-20-a-feature-a-day-1/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
