<?xml-stylesheet type="text/xsl" href="/rss.xsl" media="screen"?><rss version="2.0"><channel><title>softlogger Latest Articles ::Ruby-on-Rails</title><link>http://softlogger.com</link><description>softlogger Latest Articles ::Ruby-on-Rails</description><ttl>180</ttl><item><title>Dealing with HTTP errors in a Flex with Rails application.</title><link>http://softlogger.com/19516/Ruby-on-Rails/dealing-with-http-errors-in-a-flex-with-rails-application.aspx</link><description>&lt;p&gt;The Flash Player is restricted in the way it deals with &lt;span class="caps"&gt;HTTP&lt;/span&gt; errors. This is mainly due to provide cross browser consistency and I believe is due to the restrictions the browser imposes on the Flash Player plugin. In fact when your Flex application performs &lt;span class="caps"&gt;HTTP&lt;/span&gt; requests using the HTTPService class, the request is passed by the Flash Player to the browser and in case of an Rails error (500, 404, ...) the response is somehow crippled on the way back.&lt;/p&gt;


&lt;h2&gt;Problem&lt;/h2&gt;
So let&amp;#8217;s consider that the Flex application requests to update a Person but the validation fails. In the update method of our Rails controller the &lt;span class="caps"&gt;HTTP&lt;/span&gt; Status is set to :unprocessable_entity. This corresponds the &lt;span class="caps"&gt;HTTP&lt;/span&gt; error code 422.

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;  # PUT /people/1
  # PUT /people/1.xml
  def update
    @person = Person.find(params[:id])

    respond_to do |format|
      if @person.update_attributes(params[:person])
        flash[:notice] = 'Person was successfully updated.'
        format.html { redirect_to(@person) }
        format.xml  { head :ok }
      else
        format.html { render :action =&amp;gt; &amp;quot;edit&amp;quot; }
        format.xml  { render :xml =&amp;gt; @person.errors, :status =&amp;gt; :unprocessable_entity }
      end
    end
  end&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Now in our Flex application by default we cannot identify that the error 422 occured, more annoyingly we cannot retrieve the Rails error messages. All we get back is the following:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;[FaultEvent fault=[RPC Fault faultString=&amp;quot;HTTP request error&amp;quot; faultCode=&amp;quot;Server.Error.Request&amp;quot; faultDetail=&amp;quot;Error: [IOErrorEvent type=&amp;quot;ioError&amp;quot; bubbles=false cancelable=false eventPhase=2 text=&amp;quot;Error #2032: Stream Error. URL: http://localhost:3000/people/8.xml?_method=put&amp;quot;]. URL: http://localhost:3000/people/8.xml?_method=put&amp;quot;] messageId=&amp;quot;65EBBA92-5911-68D2-1710-18A687C28455&amp;quot; type=&amp;quot;fault&amp;quot; bubbles=false cancelable=true eventPhase=2]&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Solution&lt;/h2&gt;

	&lt;p&gt;I haven&amp;#8217;t found a way to have the status code and error message appear in the Flex application without having to change the Rails application. But fortunately, I was able to deal with that by using an after_filter at the application controller level, hence having only one place in the application to take care of all controllers and requests. The trick is to &amp;#8220;hide&amp;#8221; the &lt;span class="caps"&gt;HTTP&lt;/span&gt; Status error code in Rails and as the Flex application deals with &lt;span class="caps"&gt;XML&lt;/span&gt; responses, simply check in Flex if the response starts with &amp;lt;errors&amp;gt;. This can then also be dealt with in the Flex application in one place of the application. In a Cairngorm application I had the Delegate transform these &amp;#8220;errors&amp;#8221; responses to Faults.&lt;/p&gt;


	&lt;p&gt;Here is an example of the change to the Rails ApplicationController.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;class ApplicationController &amp;lt; ActionController::Base

  after_filter :flex_error_handling

  def flex_error_handling
    response.headers['Status'] = interpret_status(200) if response.headers['Status'] == interpret_status(422)
  end

  def rescue_action_in_public(exception)
    render_exception(exception)
  end
  def rescue_action_locally(exception)
    render_exception(exception)
  end

  rescue_from ActiveRecord::RecordNotFound, :with =&amp;gt; :render_exception
  def render_exception(exception)
    render :text =&amp;gt; &amp;quot;&amp;lt;errors&amp;gt;&amp;lt;error&amp;gt;#{exception}&amp;lt;/error&amp;gt;&amp;lt;/errors&amp;gt;&amp;quot;, :status =&amp;gt; 200 
  end

end&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=19516"&gt;</description><author>OnRails.org</author><pubDate>2008-02-20T00:00:00</pubDate><category>Ruby on Rails</category></item><item><title>IronRuby vs. Ruby.NET?</title><link>http://softlogger.com/19169/Ruby-on-Rails/ironruby-vs-ruby-net.aspx</link><description>
&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;p&gt;&lt;a title="Sheesh by John Lam, on Flickr" href="http://www.flickr.com/photos/john_lam/2158028887/"&gt;&lt;img height="332" alt="Sheesh" src="http://farm3.static.flickr.com/2398/2158028887_c5c7115629_o.jpg" width="500"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;In the spirit of Jon Udell's &lt;a href="http://blog.jonudell.net/2007/04/10/too-busy-to-blog-count-your-keystrokes/"&gt;Principle of Keystroke Conservation&lt;/a&gt;, I'm posting a follow-up to M. David Peterson's write-up on the &lt;a href="http://www.oreillynet.com/windows/blog/2008/01/rubynet_vs_ironruby_whats_the.html"&gt;differences between Ruby.NET and IronRuby&lt;/a&gt; here.&lt;/p&gt; &lt;p&gt;David observes correctly that the key difference between the two implementations is IronRuby's dependency on the DLR. The DLR provides some important benefits for languages that target it:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;A shared code generation engine. It's a lot easier to use our code generation APIs than Reflection.Emit, so this saves time for compiler implementers. This also means that future performance improvements in the DLR show up for free in your favorite DLR-targeted programming language.  &lt;li&gt;A shared hosting interface. We act as a broker between the host and the programming language. You target the DLR, and our programming languages (and others that we don't create but target the DLR) come along with no extra effort on your part. My team is building hosts for both Silverlight and ASP.NET.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;There's a few quotes that I would like to clarify:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;“Do I want the increased interop between a broader base of languages provided by the CLR (and therefore go with &lt;a href="http://rubydotnet.googlegroups.com/web/Home.htm"&gt;Ruby.NET&lt;/a&gt;), or do I want the performance gained for dynamic languages by the DLR, (and therefore go with &lt;a href="http://www.ironruby.net/"&gt;IronRuby&lt;/a&gt;)?”&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;I don't think that you lose anything in terms of interop with existing CLR-based languages by targeting the DLR. While it's certainly true that there's a lot that we can do to make dynamic dispatch better in existing CLR-based languages (would you rather call Office APIs from C# or VB.NET?) there's nothing today that prevents you from calling IronRuby library code from C#. As long as you do so via our hosting interfaces[1], things should just work. It's unclear to me how you can call arbitrary Ruby.Net code from C# without having to pass along all of the context goo that languages like Ruby require.&lt;/p&gt; &lt;p&gt;Here's another:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;"the dynamically compiled nature of IronRuby fits well into the much less predictable world of client-side applications, where as the statically compiled nature of Ruby.NET fits well into the much more predictable world of server-side applications."&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;A key advantage of the static compilation model of Ruby.NET is minimizing cold start time. They still have CLR cold start to deal with since their assemblies must be JIT-ed whereas IronRuby needs to generate IL *and* JIT the code. So I would turn this argument around and say that for client apps where cold start time is crucial that this is an advantage for Ruby.NET. That said, we used to have an AOT compilation model for IronPython, and have since removed it from the feature list of DLR 1.0. This is something we would like to revisit in the version after 1.0.&lt;/p&gt; &lt;p&gt;[1] Bill Chiles on my team has been working hard on updating the hosting spec. I've got an updated version that I'll post in a separate blog post.&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href="http://feeds.feedburner.com/~a/LessIsBetter?a=QY3LNd"&gt;&lt;img src="http://feeds.feedburner.com/~a/LessIsBetter?i=QY3LNd" border="0"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/LessIsBetter?a=oFaKeMD"&gt;&lt;img src="http://feeds.feedburner.com/~f/LessIsBetter?i=oFaKeMD" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/LessIsBetter?a=YXUWQVD"&gt;&lt;img src="http://feeds.feedburner.com/~f/LessIsBetter?i=YXUWQVD" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/LessIsBetter?a=xISFXGD"&gt;&lt;img src="http://feeds.feedburner.com/~f/LessIsBetter?i=xISFXGD" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LessIsBetter/~4/209968806" height="1" width="1"/&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=19169"&gt;</description><author>Less is better</author><pubDate>2008-02-13T00:00:00</pubDate><category>Ruby on Rails</category></item><item><title>Interesting Ruby Tidbits That Don't Need Separate Posts #14</title><link>http://softlogger.com/18247/Ruby-on-Rails/interesting-ruby-tidbits-that-don-t-need-separate-posts-14.aspx</link><description>&lt;p&gt;&lt;strong&gt;Rubular - Online Ruby Regular Expression Editor&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.rubyinside.com/wp-content/uploads/2008/01/rubular.png" width="316" height="237" alt="rubular.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rubular.com/"&gt;Rubular&lt;/a&gt; is a new Web-based regular expression editor and tester for Ruby developers, and particularly well suited for those who don't find regular expressions particularly easy. Very slick.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;FXRuby Book Available&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.rubyinside.com/wp-content/uploads/2008/01/fxruby.png" width="157" height="188" alt="fxruby.png" /&gt;&lt;/p&gt;
&lt;p&gt;Harmon Vinson reports that a new book is available in beta form from the Pragmatic Programmers, namely "&lt;a href="http://www.pragprog.com/titles/fxruby"&gt;FXRuby: Create Lean and Mean GUIs with Ruby.&lt;/a&gt;" As you can expect, the book covers how to create GUI applications using Ruby and the cross-platform &lt;a href="http://www.fox-toolkit.org/"&gt;FOX widgets library&lt;/a&gt; using FXRuby. The only downside is that FOX, so far, has no native support for OS X's default Aqua window manager, but will work through X11.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Ruport Book Available&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.rubyinside.com/wp-content/uploads/2008/01/320_1700117.jpg" width="183" height="240" alt="320_1700117.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-style: italic;"&gt;The Ruport Book&lt;/span&gt;, "Your Guide to mastering Ruby Reports", is &lt;a href="http://www.lulu.com/content/1700117"&gt;now available to buy&lt;/a&gt; in both PDF and print form. The book covers the use of the popular &lt;a href="http://rubyreports.org/"&gt;Ruport Ruby Reports&lt;/a&gt; library and is by Gregory Brown and Michael Milner. If you're already using the Ruport library, this is a must buy.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Encrypted Cookies for Rails 2&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Aaron Bedra takes a look at &lt;a href="http://aaronbedra.com/2008/1/13/baking-the-special-kind-of-cookies"&gt;how you can get Rails to encrypt the cookies&lt;/a&gt; that go between your application and its users.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Faster Rails Routing (6.4x Faster!) On The Way&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Michael Klishin writes in with news that Oleg Andreev has come up with &lt;a href="http://novemberain.com/2008/1/17/routes-recognition"&gt;a smart way to radically increase the performance of Rails' routing code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Free Git Hosting&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Johan Sørensen wanted everyone to know about his new open-source &lt;a href="http://gitorious.org/"&gt;Gitorious&lt;/a&gt; project, which provides free Git repository hosting. As many Rails coders have switched from Subversion to Git recently, this deserves a mention on Ruby Inside. It is also worth giving &lt;a href="http://github.com/"&gt;Github&lt;/a&gt;, a similar site by Tom Preston-Werner and Chris Wanstrath, a mention although it is not accepting signups just yet.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://feeds.feedburner.com/~a/RubyInside?a=ZtP0oN"&gt;&lt;img src="http://feeds.feedburner.com/~a/RubyInside?i=ZtP0oN" border="0"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/RubyInside?a=UXVgOLD"&gt;&lt;img src="http://feeds.feedburner.com/~f/RubyInside?i=UXVgOLD" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/RubyInside?a=3Axfiid"&gt;&lt;img src="http://feeds.feedburner.com/~f/RubyInside?i=3Axfiid" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/RubyInside?a=NLNZcQd"&gt;&lt;img src="http://feeds.feedburner.com/~f/RubyInside?i=NLNZcQd" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/RubyInside/~4/220002638" height="1" width="1"/&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=18247"&gt;</description><author>Ruby Inside</author><pubDate>2008-01-20T00:00:00</pubDate><category>Ruby on Rails</category></item><item><title>Aliasing Global Variables in Ruby</title><link>http://softlogger.com/16693/Ruby-on-Rails/aliasing-global-variables-in-ruby.aspx</link><description>&lt;p&gt;And while I am becoming quite the language lawyer, I should mention that Ruby&amp;#8217;s &lt;code&gt;alias&lt;/code&gt; statement treats global variables quite differently from other kinds of variables.&lt;/p&gt;


	&lt;p&gt;When aliasing global symbols, the global variable itself is aliased and not evaluated. The result is a true alias, not a copy, so you cannot modify the global and its alias independently.&lt;/p&gt;


	&lt;p&gt;This feature most likely exists solely for &lt;code&gt;English.rb&lt;/code&gt; in the standard library. This being the case, see that file for examples.&lt;/p&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=16693"&gt;</description><author>jvoorhis</author><pubDate>2008-01-05T00:00:00</pubDate><category>Ruby on Rails</category></item><item><title>Freezing Your Rails Application</title><link>http://softlogger.com/16190/Ruby-on-Rails/freezing-your-rails-application.aspx</link><description>
            &lt;p&gt;&lt;img src="http://farm1.static.flickr.com/5/5233730_8e80341d1f.jpg?v=0" alt="Ice cubes" /&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.flickr.com/photos/victory/5233730/"&gt;Photo credit&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Thanks to all &lt;a href="http://softiesonrails.com/2007/12/17/rails-2-0-2"&gt;who asked&lt;/a&gt; for an article about “freezing” your Rails application.  I’ll try to cover all the basics, but
feel free to follow up with more questions by leaving a comment below.&lt;/p&gt;


	&lt;h2&gt;You on Gems&lt;/h2&gt;


	&lt;p&gt;Talking about “freezing” your Rails app won’t make sense if you don’t first understand what Ruby Gems are all about.  
Even if you’re new to Rails, you already know at least a little bit about gems, because you can’t install Rails without  learning this command:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;gem install rails
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;(or &lt;code&gt;sudo gem install rails&lt;/code&gt; if you’re on Mac/Linux).&lt;/p&gt;


	&lt;p&gt;Gems are the official way to share Ruby code with your friends, coworkers, and enemies.  The RubyGems system is accessed with the &lt;code&gt;gem&lt;/code&gt; utility, like we just did when we installed the Rails gems.  In fact, for us Windows users, RubyGems is kind of like your new version of the Add/Remove Programs applet that comes with Windows.  Using the &lt;code&gt;gem&lt;/code&gt; command, you can install, upgrade, and uninstall Ruby code that you don’t write yourself.&lt;/p&gt;


	&lt;p&gt;Imagine a world without RubyGems.  You write some cool Ruby class and want to send it to me.  You could just email it, I guess.  I’d have to copy it onto my machine, and then &lt;code&gt;require&lt;/code&gt; it from within my code, using the full path to wherever I copied it to.  Not a big deal, I suppose.  If many people sent my their Ruby code, I’d probably create a folder for all of “everyone else’s stuff” and put it all in there.&lt;/p&gt;


	&lt;h2&gt;Could Be Raining&lt;/h2&gt;


	&lt;p&gt;But it could get worse.  Instead of one .rb file, you want to send me your whole Ruby code library, spread across 9 different files.  Or you’d probably zip it up into one file.  Now this is starting to become a hassle.  Because not only do I need to remember where I’m keeping all this code, I’m sure that the very next day you’re going to say you fixed something and you’re going to want me to upgrade to the newest stuff. Oh and it depends on this other zip file from this other guy, so I have to make sure I have that on my computer, too.&lt;/p&gt;


	&lt;p&gt;A Gem is like a zip file of Ruby code, except it also gets stamped with metadata about the code inside.  Like who wrote it, a version number, and if it depends on any other gems.  Instead of .zip, it gets an extension of .gem, and it’s the standard &lt;em&gt;package format&lt;/em&gt; for third-party Ruby code.  It makes it easy for us to all share code.&lt;/p&gt;


	&lt;p&gt;The &lt;code&gt;gem&lt;/code&gt; utility can automatically find gem files in well-known locations on the internet, download them for us, upgrade them, and remove them.  If you’ve never done it, do a &lt;code&gt;gem list&lt;/code&gt; right now to see what gems you have installed.&lt;/p&gt;


	&lt;h2&gt;Your Application on Gems&lt;/h2&gt;


	&lt;p&gt;Like it or not, every Rails application you write depends upon the presence of certain gems having been installed on the same computer that’s running the application.  Those gems are the Rails gems of course.  Rails is a gem that depends upon other gems like activerecord, actionpack, activeresource, activesupport, actionmailer, and rake.  (The gems that you must have to run every Rails app are: rails, activerecord, actionpack, and activesupport. Actionmailer and activeresource can be omitted if you’re not using those features.)&lt;/p&gt;


	&lt;p&gt;This means that when you publish your application on the internet – that is, you’ve &lt;a href="http://www.softiesonrails.com/2007/4/5/the-absolute-moron-s-guide-to-capistrano"&gt;deployed it to some server&lt;/a&gt; – that server also better have those gems installed, or your application will fail pretty quickly.  This is why, if you’re looking at shared hosting providers, you have to find out if they support Rails, which really means do they have the Ruby interpreter and the necessary gems installed.&lt;/p&gt;


	&lt;p&gt;So if you’re with me so far, you know that you have some gems installed on your development box that make your Rails app work, and there are gems on the server that make your app work there, too.  Good, right?&lt;/p&gt;


	&lt;p&gt;No.  Not good.&lt;/p&gt;


	&lt;p&gt;Very, very bad.&lt;/p&gt;


	&lt;h2&gt;Versions, Versions, And More Versions&lt;/h2&gt;


	&lt;p&gt;Consider:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;You’ve upgraded to Rails 2.0 and are using all the new stuff in it.  But your server still has 1.2.3 on it. &lt;/li&gt;
		&lt;li&gt;You’re writing apps for Rails 1.2.5 and your hosting provider just upgraded all of their gems to 2.0. &lt;/li&gt;
		&lt;li&gt;You have an app written for 1.2.4, deployed and doing just fine.  Now you want to deploy a 2.0 app on the same server.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;It turns out that you can have multiple versions of a gem installed on the same machine.  There’s a line in your &lt;code&gt;environment.rb&lt;/code&gt; file that connects your application to a specific version of the Rails gems, and it looks something like this:&lt;/p&gt;


&lt;pre&gt;&lt;code class="ruby"&gt;# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '1.2.3'
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;In this example, the application will look for the 1.2.3 version of Rails.  If your server has it, all is good. If not, ouch.&lt;/p&gt;


	&lt;p&gt;So theoretically, all you have to do is always keep all versions of Rails that you need for all of your applications.&lt;/p&gt;


	&lt;p&gt;On every server.&lt;/p&gt;


	&lt;p&gt;All the time.&lt;/p&gt;


	&lt;p&gt;Forever.&lt;/p&gt;


	&lt;p&gt;Not good.  And probably not even possible if you’re under a shared hosting plan (or if you’re not the boss of your IT department).&lt;/p&gt;


	&lt;h2&gt;We’re Getting Warmer – I Mean, Colder&lt;/h2&gt;


	&lt;p&gt;By now, I hope you now understand the problem.&lt;/p&gt;


	&lt;p&gt;Here’s the solution.  Instead of having your application search the system-wide gems for the appropriate gems, you can “override” that search by placing copies of the desired gems right into a subfolder of your Rails app.  If you re-read that line from your environment.rb file, you’ll notice the comment above it, which implies that Rails will first search a subfolder in your Rails app named “vendor/rails” for the Rails gems, before it goes looking elsewhere for them.&lt;/p&gt;


	&lt;p&gt;All you need to do, then, is copy the gems into your vendor/rails subfolder, right?&lt;/p&gt;


	&lt;p&gt;Well, no, unfortunately.  Technically speaking you have to “unpack” them, not just copy them.  Unpacking a gem is kind of like unzipping a zip file.  The gem utility provides an &lt;code&gt;unpack&lt;/code&gt; command to do just that.  So you have to do unpack each Rails gem that your app needs into the a subdirectory heirarchy under vendor/rails.&lt;/p&gt;


	&lt;p&gt;You can do all that by hand, if you want to.  Fortunately, Rails comes with a prewritten &lt;code&gt;rake&lt;/code&gt; task to it all for you.&lt;/p&gt;


	&lt;h2&gt;Freeze That App!&lt;/h2&gt;


	&lt;p&gt;Freezing your application will make a copy of your system-wide gems and unpack them into your Rails app.  As always, run rake tasks from the “root” directory of your Rails application:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;c:\dev\myapp&amp;gt; rake rails:freeze:gems
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;You’ll now find &lt;code&gt;c:\dev\myapp\vendor\rails&lt;/code&gt; has been created and populated with the latest version of your Rails gems.  You can now deploy your Rails app anywhere regardless the version of Rails has been installed on the server.  Your application will always use the gems you’ve frozen to it.&lt;/p&gt;


	&lt;h2&gt;Thaw That App!&lt;/h2&gt;


	&lt;p&gt;You can reverse the process:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;c:\dev\myapp&amp;gt; rake rails:unfreeze
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;This toasts the &lt;code&gt;vendor/rails&lt;/code&gt; directory.  Now when your application starts up, it won’t find anything there, and will resort to looking for Rails in the system-wide gem repository instead.  Or, you can now re-freeze to your latest and greatest version.  (If all you want to do is re-freeze a frozen app, no need to thaw first, just run &lt;code&gt;rake rails:freeze:gems&lt;/code&gt; again.)&lt;/p&gt;


	&lt;h2&gt;Freezing To Edge&lt;/h2&gt;


	&lt;p&gt;You maybe have heard the term “freeze to edge rails.”  Turns out, in addition to freezing your application to a released version of Rails, you can download the latest bleeding-edge Rails bits and unpack them into vendor/rails.  That means that you’ll be able to get the latest bug fixes and newest features (and newest bugs, too).  Since you’re doing this to your application only, it’s not touching your stable Rails gems that you’ve installed system wide.  This is a great way to try out the latest features in Rails.&lt;/p&gt;


	&lt;p&gt;Don’t know how to download the latest Rails code by hand?  Yet again, another rake task comes to the rescue (actaully, two):&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;c:\dev\myapp&amp;gt; rake rails:freeze:edge
c:\dev\myapp&amp;gt; rake rails:update
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;That second rake task makes sure that your javascript files and other configuration files that were originally generated when you issued the &lt;code&gt;rails&lt;/code&gt; command get updated with the latest versions from edge. (&lt;a href="http://dev.rubyonrails.org/ticket/10565"&gt;Our patch&lt;/a&gt; has made this second step obsolete, so in Rails 2.0.3 you won’t have to do the &lt;code&gt;rails:update&lt;/code&gt; step anymore).&lt;/p&gt;


	&lt;p&gt;I always have an “edge” app on my box, that I just keep re-freezing to edge so I can play with the latest stuff going into Rails.&lt;/p&gt;


	&lt;h2&gt;Warnings&lt;/h2&gt;


	&lt;p&gt;Rails 1.x doesn’t necessarily freeze well with RubyGems version 1.0 and higher.  If get a strange-looking “GemRunner”-related error when you try to freeze, that’s what’s happening.  There’s a workaround – google for the solution, or let me know and I’ll try to post an article about that, too.&lt;/p&gt;


	&lt;p&gt;Also, the same version hassles can occur with any other gems you might be using in addition to your Rails app.  &lt;a href="http://errtheblog.com/posts/50-vendor-everything"&gt;Read this&lt;/a&gt; for how to solve that, too.&lt;/p&gt;


	&lt;p&gt;So have fun with edge, and always freeze your apps before deployment.&lt;/p&gt;


	&lt;h2&gt;Cool?&lt;/h2&gt;


	&lt;p&gt;Questions?  Comments?  Let us know.&lt;/p&gt;
          
&lt;p&gt;&lt;a href="http://feeds.feedburner.com/~a/SoftiesOnRails?a=HyINbh"&gt;&lt;img src="http://feeds.feedburner.com/~a/SoftiesOnRails?i=HyINbh" border="0"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/SoftiesOnRails?a=0Rp8FCd"&gt;&lt;img src="http://feeds.feedburner.com/~f/SoftiesOnRails?i=0Rp8FCd" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/SoftiesOnRails?a=ShAjFGd"&gt;&lt;img src="http://feeds.feedburner.com/~f/SoftiesOnRails?i=ShAjFGd" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/SoftiesOnRails?a=AN0ZowD"&gt;&lt;img src="http://feeds.feedburner.com/~f/SoftiesOnRails?i=AN0ZowD" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/SoftiesOnRails?a=2ohddOD"&gt;&lt;img src="http://feeds.feedburner.com/~f/SoftiesOnRails?i=2ohddOD" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/SoftiesOnRails/~4/210647224" height="1" width="1"/&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=16190"&gt;</description><author>Softies on Rails</author><pubDate>2008-01-05T00:00:00</pubDate><category>Ruby on Rails</category></item><item><title>What's New in Edge Rails: Better Cross-Site Request Forging Prevention</title><link>http://softlogger.com/16677/Ruby-on-Rails/what-s-new-in-edge-rails-better-cross-site-request-forging-prevention.aspx</link><description>
            &lt;p&gt;Hot on the heels of the in-depth look at &lt;a href="http://www.quarkruby.com/2007/9/20/ruby-on-rails-security-guide"&gt;Rails security options&lt;/a&gt; comes the addition of the &lt;a href="http://projects.wh.techno-weenie.net/browser/plugins/csrf_killer"&gt;CsrfKiller plugin&lt;/a&gt; &lt;a href="http://dev.rubyonrails.org/changeset/7592"&gt;into rails core&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;The CsrfKiller plugin adds a unique session token field to all forms that is checked on every non-GET request.  This ensures that the request received is in fact coming from the session of the authorized user (check out &lt;a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery"&gt;wikipedia’s &lt;span class="caps"&gt;CSRF&lt;/span&gt; article&lt;/a&gt; if you need more details on the technique).&lt;/p&gt;


	&lt;p&gt;&lt;del&gt;All you need to do to enable this protection is to add a &lt;code&gt;protect_from_forgery&lt;/code&gt; statement in your controller that takes the familiar &lt;code&gt;:except&lt;/code&gt; or &lt;code&gt;:only&lt;/code&gt; option along with salt to use when generating the unique token:&lt;/del&gt;&lt;/p&gt;


	&lt;p&gt;&lt;em&gt;And now this is the &lt;a href="http://dev.rubyonrails.org/changeset/7620"&gt;default functionality&lt;/a&gt;.  No need to specify anything if you want the default behavior.  You can still override as in the following examples, however.&lt;/em&gt;&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&lt;span class="r"&gt;class&lt;/span&gt; &lt;span class="cl"&gt;PostsController&lt;/span&gt; &amp;lt; &lt;span class="co"&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  protect_from_forgery &lt;span class="sy"&gt;:secret&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;2kdjnaLI8&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="sy"&gt;:only&lt;/span&gt; =&amp;gt; [&lt;span class="sy"&gt;:update&lt;/span&gt;, &lt;span class="sy"&gt;:delete&lt;/span&gt;, &lt;span class="sy"&gt;:create&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;  ...&lt;tt&gt;
&lt;/tt&gt;&lt;span class="r"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;If you’re already using edge Rails’ default &lt;a href="/articles/2007/2/21/what-s-new-in-edge-rails-cookie-based-sessions"&gt;cookie session store&lt;/a&gt; then you don’t have to specify the &lt;code&gt;:secret&lt;/code&gt; key.&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;protect_from_forgery &lt;span class="sy"&gt;:only&lt;/span&gt; =&amp;gt; [&lt;span class="sy"&gt;:update&lt;/span&gt;, &lt;span class="sy"&gt;:delete&lt;/span&gt;, &lt;span class="sy"&gt;:create&lt;/span&gt;]&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;If you’re not on a cookie session store you can also change the digest method used to generate the unique token (the default is ‘SHA1’).&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;  protect_from_forgery &lt;span class="sy"&gt;:secret&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;2kaienna9ea90djnaLI8&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="sy"&gt;:digest&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;MD5&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;If a request comes in that doesn’t match the request forgery protection token for the current session then an &lt;code&gt;ActionController::InvalidAuthenticityToken&lt;/code&gt; exception will be thrown.  Perhaps a good place to try out the &lt;a href="/articles/2007/9/24/what-s-new-in-edge-rails-better-exception-handling"&gt;new exception handling syntax&lt;/a&gt; ?&lt;/p&gt;


&lt;em&gt;Caveats:&lt;/em&gt; The request forgery protection only kicks in in the following scenarios:
	&lt;ul&gt;
	&lt;li&gt;Non-GET requests, so make sure the only requests that modify state are your &lt;code&gt;PUT&lt;/code&gt;/&lt;code&gt;POST&lt;/code&gt;/&lt;code&gt;DELETE&lt;/code&gt; requests.&lt;/li&gt;
		&lt;li&gt;On html and ajax requests.  Override &lt;code&gt;verifiable_request_format?&lt;/code&gt; if you want to expand that.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;And what to do if you want to disable &lt;span class="caps"&gt;CSRF&lt;/span&gt; protection?  Just add this to whatever controllers you don’t want to be affected:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;skip_before_filter &lt;span class="sy"&gt;:verify_authenticity_token&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;And if you want to disable this site-wide, just add this to &lt;code&gt;application.rb&lt;/code&gt;:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&lt;span class="pc"&gt;self&lt;/span&gt;.allow_forgery_protection = &lt;span class="pc"&gt;false&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;tags: &lt;a href="http://technorati.com/tag/ruby"&gt;ruby&lt;/a&gt;,
&lt;a href="http://technorati.com/tag/rubyonrails"&gt;rubyonrails&lt;/a&gt;&lt;/p&gt;
          
&lt;p&gt;&lt;a href="http://feeds.feedburner.com/~a/RyansScraps?a=J8cyGV"&gt;&lt;img src="http://feeds.feedburner.com/~a/RyansScraps?i=J8cyGV" border="0"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/RyansScraps?a=xIk77ujI"&gt;&lt;img src="http://feeds.feedburner.com/~f/RyansScraps?i=xIk77ujI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/RyansScraps?a=f0x2GDF3"&gt;&lt;img src="http://feeds.feedburner.com/~f/RyansScraps?i=f0x2GDF3" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/RyansScraps?a=vTJQ6hps"&gt;&lt;img src="http://feeds.feedburner.com/~f/RyansScraps?i=vTJQ6hps" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/RyansScraps?a=bxHmkKlG"&gt;&lt;img src="http://feeds.feedburner.com/~f/RyansScraps?i=bxHmkKlG" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=16677"&gt;</description><author>Ryans Scraps</author><pubDate>2008-01-05T00:00:00</pubDate><category>Ruby on Rails</category></item><item><title>RailsJitsu :: Programming Beautiful Ruby on Rails Code Part 1</title><link>http://softlogger.com/15027/Ruby-on-Rails/railsjitsu--programming-beautiful-ruby-on-rails-code-part-1.aspx</link><description>In this article I would like to go through a list of things I have learned on how to write more readable, more beautiful, more functional Ruby and Rails code. No one learns in a vacuum (well, except f...&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=15027"&gt;</description><author>RubyCorner</author><pubDate>2007-12-25T00:00:00</pubDate><category>Ruby on Rails</category></item><item><title>Interesting Rails Tidbits #1</title><link>http://softlogger.com/14099/Ruby-on-Rails/interesting-rails-tidbits-1.aspx</link><description>&lt;p&gt;We're taking a brief break from the regular "Interesting Ruby Tidbits" posts to focus on Rails™ only for a change. Rails has just made it to version 2.0 so there's been plenty of action in the community. Here are some of the highlights:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The First Rails 2.0 Screencast&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I can't confirm the validity of its title, but &lt;a href="http://www.akitaonrails.com/2007/12/10/the-first-rails-2-0-screencast-english"&gt;The First Rails 2.0 Screencast&lt;/a&gt; is a screencast by Fabio Akita that walks through building a RESTful blog system in 30 minutes using Rails 2.0.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;PeepCode Rails2 PDF (now in Spanish too!)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;img src="http://www.rubyinside.com/wp-content/uploads/2007/12/rails2bookes.png" width="216" height="114" /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;"&lt;a href="http://peepcode.com/products/rails2-pdf"&gt;Rails2&lt;/a&gt;" is a 58-page e-book (available in PDF format) by Ryan Daigle and published by Geoffrey Grosenbach's Peepcode that demonstrates how to use Rails 2.0's new features. A &lt;a href="https://peepcode.com/products/rails-2-pdf-es"&gt;Spanish version&lt;/a&gt; has also now been published. It's available por solo $9 por senors y senoritas.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;BackgroundFu - Background task runner plugin for Rails that isn't BackgrounDRB&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://trix.pl/blog/ruby-on-rails/running-long-background-tasks-in-ruby-on-rails-made-dead-simple"&gt;BackgroundFu&lt;/a&gt; is a new Rails plugin that enables you to run arbitrary background / long-running tasks in relation to a Rails application. It differs from the more established &lt;a href="http://backgroundrb.rubyforge.org/"&gt;BackgrounDRB&lt;/a&gt; by being more suitable for arbitrary, on-the-go long running tasks, rather than routine background tasks. There appear to be a number of downsides to BackgroundFu's approach, however, which are clarified in the comments associated with &lt;a href="http://trix.pl/blog/ruby-on-rails/running-long-background-tasks-in-ruby-on-rails-made-dead-simple"&gt;this post&lt;/a&gt;. One worth watching for the future though.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;10 Ruby on Rails Plugins You Should Be Using&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://hosting.media72.co.uk/blog/2007/12/09/10-ruby-on-rails-plugins-you-should-be-using/"&gt;10 Ruby on Rails Plugins You Should Be Using&lt;/a&gt; is an article that pretty much covers what it says in the title. The author looks at ten different useful Rails plugins and gives a reason for their inclusion in the list. Amongst the ten are attachment_fu, white_list, Rspec and autotest.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Rendering with Erubis on Rails 2.0&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In &lt;a href="http://railspikes.com/2007/12/10/rendering-erubis-and-rails-2-0"&gt;Rendering with Erubis and Rails 2.0&lt;/a&gt;, Eric X shows how to replace the default Erb rendering library with the faster, more powerful &lt;a href="http://www.kuwata-lab.com/erubis/"&gt;Erubis&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Declarative Exception-Handling in Rails 2.0&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Chu Yeow &lt;a href="http://blog.codefront.net/2007/12/10/declarative-exception-handling-in-your-controllers-rails-20-a-feature-a-day-2/"&gt;demonstrates&lt;/a&gt; the very clean way in which you can handle controller-level exceptions in Rails 2.0.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://feeds.feedburner.com/~a/RubyInside?a=YI76fm"&gt;&lt;img src="http://feeds.feedburner.com/~a/RubyInside?i=YI76fm" border="0"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/RubyInside?a=IYswjuC"&gt;&lt;img src="http://feeds.feedburner.com/~f/RubyInside?i=IYswjuC" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/RubyInside?a=jhCpIKc"&gt;&lt;img src="http://feeds.feedburner.com/~f/RubyInside?i=jhCpIKc" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/RubyInside?a=Xc7fwTc"&gt;&lt;img src="http://feeds.feedburner.com/~f/RubyInside?i=Xc7fwTc" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/RubyInside/~4/199117406" height="1" width="1"/&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=14099"&gt;</description><author>Ruby Inside</author><pubDate>2007-12-12T00:00:00</pubDate><category>Ruby on Rails</category></item><item><title>Softies on Rails Interviews: Orbitz</title><link>http://softlogger.com/13579/Ruby-on-Rails/softies-on-rails-interviews-orbitz.aspx</link><description>
            &lt;p&gt;Orbitz is one of the largest companies in the online travel business, and from a web development standpoint, heavily invested in enterprise technologies like J2EE and Oracle.  So I was pleased to learn that over the past several months, a small team at Orbitz has been working hard on a project called &lt;a href="http://updates.orbitz.com/"&gt;Traveler Update&lt;/a&gt; (maybe you've seen the TV commercials), and it's built entirely with Rails.  I recently had the pleasure of meeting Doug Breaker, who's led the team at Orbitz through the project's development and recent launch.&lt;/p&gt;

&lt;p&gt;Thanks to Doug and his team for this e-mail interview.&lt;/p&gt;
&lt;p&gt;Orbitz is one of the largest companies in the online travel business, and from a web development standpoint, heavily invested in enterprise technologies like J2EE and Oracle.  So I was pleased to learn that over the past several months, a small team at Orbitz has been working hard on a project called &lt;a href="http://updates.orbitz.com/"&gt;Traveler Update&lt;/a&gt; (maybe you've seen the TV commercials), and it's built entirely with Rails.  I recently had the pleasure of meeting Doug Breaker, who's led the team at Orbitz through the project's development and recent launch.&lt;/p&gt;

&lt;p&gt;Thanks to Doug and his team for this e-mail interview.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tell us a bit about what your service is all about.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The product we launched on Rails is called Traveler Update, you can find it at &lt;a href="http://updates.orbitz.com/"&gt;http://updates.orbitz.com&lt;/a&gt; on the web, and &lt;a href="http://mobile.orbitz.com/"&gt;http://mobile.orbitz.com&lt;/a&gt; on your phone.  We set out to make peoples' day of travel less stressful and more enjoyable.  The site combines a bunch of real-time, and near-real-time travel condition information, with updates and tips that travelers send in while they're traveling.  One the day of your trip, you can go to the site to get your latest flight status, the airport status from Orbitz's team of air traffic experts and the FAA, live traffic delays, the latest weather, average security line wait times from the TSA, parking and wifi guides, and updates and tips from people actually traveling.  All of the info is available both on the website, and on the mobile site.&lt;/p&gt;

&lt;p&gt;Orbitz is one of the largest online travel agencies, we sell millions of airline tickets, hotels, and car rentals a year.  Unlike other online travel agencies, we staff a seasoned team of experts that monitors nationwide travel conditions for our travelers around the clock, every day, and alert our travelers when conditions warrant.  We wanted to build on this legacy with Traveler Update by allowing travelers to help each other out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;As you're primarily an enterprise Java shop, what was the primary motivation for you to explore Ruby/Rails and to build your app using Rails?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It actually a bit of a strange story.  Before becoming a product guy at Orbitz, Doug was a .NET developer at a previous company.  He was working on some personal projects and got really frustrated with .NET,  did some searching for something better, and found and fell in love with Rails. After joining Orbitz' Product Management group, he continued to play around with Rails for small prototypes.&lt;/p&gt;

&lt;p&gt;When we got the idea for Traveler Update late last year, he actually put together a really simple prototype in Rails, that was used to show off the concept to management, and build support for the project.  Even in its ugly form, it stirred excitement, which led us to hire a Rails consulting firm to flesh out the prototype further.  Doug looked specifically for Rails firms to do the work, since he had done the initial prototype in Rails, and wanted the full prototype done quickly, and wanted to be able to take and possibly use the finished code once they were done.  By early this spring, the outside firm had completed the prototype, and our internal developers were ready to work on the product. &lt;/p&gt;

&lt;p&gt;Initially, development planned to build the site on Orbitz' new global platform but also took a serious look at Rails based on the momentum the prototype had achieved.  When the timeframe for delivering the project on our Java platform stretched out past when the business wanted to launch, all eyes began to focus on Rails.  Timm had also been working with Rails for some personal projects the previous year and was as excited as Doug to campaign for Rails within Orbitz. After more backing and enthusiasm was gained from upper technology management, a dedicated development team was formed to work autonomously on the project.  We were tasked with the challenge of seamlessly pairing up the Traveler Update site with the existing Orbitz.com site.  The model has worked so well that other teams within the company are being formed in its image.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tell us a little bit about your team... and how long it took your team to go from concept to launch.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The core team worked using agile development practices to match the philosophy of Rails, a change from our normal style of work.  We're all full-time at Orbitz and consist of two product managers, an information architect, a designer, two rails developers, a UI developer, and of course a quality tester.  We also had Marcel Molina, a member of the Rails core team, on-site for training and consulting early in the project to help kick-start our RoR knowledge.&lt;/p&gt;

&lt;p&gt;Requirements writing began in January, but we switched to a feature-driven development model within a month, a move that made everyone happier.  Since we're still in a public beta stage, there was no hard concept of 'done' per se, but we felt comfortable enough with the progress to launch over Labor Day.   We actually could have launched earlier, but held off to better coincide with peak travel season.   We continue to iteratively improve the site with a new release every two weeks. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Were there any particular challenges you faced because you chose Rails?  Scalability?  Learning curve?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As with any brand new application, we've learned to scale through caching and distribution as usage increases. We continue to stress test and load test the site with every new iteration to find bottlenecks and optimize our application and workaround the limits of ActiveRecord. Orbitz is heavily focused on the MVC architecture so many of the best practices of Rails were easy transitions. The lightweight and flexible nature of Ruby and IRB have been a joy to work with, though it does have its quirks at times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deployment... did you choose to try and fit your app into Orbitz's existing infrastructure or outsource it?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Rails has a growing influence among Orbitz developers for both internal and external applications.  While Rails is now a mature platform for development, there is still a lack of information and support for operationalizing an app within a large enterprise.  Our infrastructure group preferred to host it externally with a dedicated Rails host at first.  We continue to evaluate where the tipping point is for building an in house Rails infrastructure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What's next for your team?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We'll keep working on making peoples' day of travel easier and less stressful. For the next few months, that means releasing a couple of features we're pretty excited about, and making improvements based on user feedback. We're pretty excited right now because we just launched an Orbitz text messaging service where you can text Orbitz (shortcode 672489) to get flight status, the airport delay information, and current weather conditions. Longer term, we want to keep learning from our users and build features that help them on their day of travel. It's hard to say what direction the site will go in until we see it, but we have some pretty good ideas about integrating further with people's existing travel itineraries, flight tracking, supporting more airports, and providing more social features.&lt;/p&gt;
          
&lt;p&gt;&lt;a href="http://feeds.feedburner.com/~a/SoftiesOnRails?a=ykx5Jg"&gt;&lt;img src="http://feeds.feedburner.com/~a/SoftiesOnRails?i=ykx5Jg" border="0"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/SoftiesOnRails?a=0ERh16c"&gt;&lt;img src="http://feeds.feedburner.com/~f/SoftiesOnRails?i=0ERh16c" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/SoftiesOnRails?a=MvqeRkc"&gt;&lt;img src="http://feeds.feedburner.com/~f/SoftiesOnRails?i=MvqeRkc" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/SoftiesOnRails?a=1q7su6C"&gt;&lt;img src="http://feeds.feedburner.com/~f/SoftiesOnRails?i=1q7su6C" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/SoftiesOnRails?a=6uppVkC"&gt;&lt;img src="http://feeds.feedburner.com/~f/SoftiesOnRails?i=6uppVkC" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/SoftiesOnRails/~4/196700004" height="1" width="1"/&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=13579"&gt;</description><author>Softies on Rails</author><pubDate>2007-12-10T00:00:00</pubDate><category>Ruby on Rails</category></item><item><title>Ruby Rake - Invoke vs Execute</title><link>http://softlogger.com/13367/Ruby-on-Rails/ruby-rake--invoke-vs-execute.aspx</link><description>&lt;p&gt;First up &amp;#8211; I don&amp;#8217;t know an awful lot about the magic that is &lt;a href="http://rake.rubyforge.org/"&gt;Rake&lt;/a&gt;.  As such, this is probably common knowledge to most people.&lt;/p&gt;


	&lt;p&gt;I discovered the difference when trying to execute the db:migrate task from within another rake task (I already knew it worked when declared as a dependency).&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="comment"&gt;# Rakefile&lt;/span&gt;
&lt;span class="ident"&gt;task&lt;/span&gt; &lt;span class="symbol"&gt;:foo&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
  &lt;span class="constant"&gt;Rake&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Task&lt;/span&gt;&lt;span class="punct"&gt;['&lt;/span&gt;&lt;span class="string"&gt;db:migrate&lt;/span&gt;&lt;span class="punct"&gt;'].&lt;/span&gt;&lt;span class="ident"&gt;execute&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;

&lt;span class="comment"&gt;#$ rake foo&lt;/span&gt;
&lt;span class="comment"&gt;#=&amp;gt; rake aborted!&lt;/span&gt;
&lt;span class="comment"&gt;#=&amp;gt; uninitialized constant ActiveRecord&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;I changed &lt;a href="http://rake.rubyforge.org/classes/Rake/Task.html#M000100"&gt;Task#execute&lt;/a&gt; to &lt;a href="http://rake.rubyforge.org/classes/Rake/Task.html#M000098"&gt;Task#invoke&lt;/a&gt; and, voila, it all worked fine.  The rdoc for those methods is actually pretty self explanatory, having seen the differences in action.  Oh well.&lt;/p&gt;


	&lt;p&gt;I put together a simple example to demonstrate the differences.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="comment"&gt;# The task (task_1) and its dependency (to_be_run_before_task_1)&lt;/span&gt;

&lt;span class="ident"&gt;task&lt;/span&gt; &lt;span class="symbol"&gt;:to_be_run_before_task_1&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
  &lt;span class="ident"&gt;puts&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;to_be_run_before_task_1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;

&lt;span class="ident"&gt;task&lt;/span&gt; &lt;span class="symbol"&gt;:task_1&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;['&lt;/span&gt;&lt;span class="string"&gt;to_be_run_before_task_1&lt;/span&gt;&lt;span class="punct"&gt;']&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
  &lt;span class="ident"&gt;puts&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;task_1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;

&lt;span class="comment"&gt;# Three tasks that 'run' task_1&lt;/span&gt;

&lt;span class="ident"&gt;task&lt;/span&gt; &lt;span class="symbol"&gt;:invoke_task_1&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
  &lt;span class="constant"&gt;Rake&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Task&lt;/span&gt;&lt;span class="punct"&gt;['&lt;/span&gt;&lt;span class="string"&gt;task_1&lt;/span&gt;&lt;span class="punct"&gt;'].&lt;/span&gt;&lt;span class="ident"&gt;invoke&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;

&lt;span class="ident"&gt;task&lt;/span&gt; &lt;span class="symbol"&gt;:execute_task_1&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
  &lt;span class="constant"&gt;Rake&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Task&lt;/span&gt;&lt;span class="punct"&gt;['&lt;/span&gt;&lt;span class="string"&gt;task_1&lt;/span&gt;&lt;span class="punct"&gt;'].&lt;/span&gt;&lt;span class="ident"&gt;execute&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;

&lt;span class="ident"&gt;task&lt;/span&gt; &lt;span class="symbol"&gt;:run_task_1_using_dependencies&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;['&lt;/span&gt;&lt;span class="string"&gt;task_1&lt;/span&gt;&lt;span class="punct"&gt;']&lt;/span&gt;

&lt;span class="comment"&gt;# 'Running' the tasks&lt;/span&gt;

&lt;span class="comment"&gt;#$ rake task_1&lt;/span&gt;
&lt;span class="comment"&gt;#=&amp;gt; to_be_run_before_task_1&lt;/span&gt;
&lt;span class="comment"&gt;#=&amp;gt; task_1&lt;/span&gt;

&lt;span class="comment"&gt;#$ rake invoke_task_1&lt;/span&gt;
&lt;span class="comment"&gt;#=&amp;gt; to_be_run_before_task_1&lt;/span&gt;
&lt;span class="comment"&gt;#=&amp;gt; task_1&lt;/span&gt;

&lt;span class="comment"&gt;#$ rake execute_task_1&lt;/span&gt;
&lt;span class="comment"&gt;#=&amp;gt; task_1 #*** Note that the dependencies are not run&lt;/span&gt;

&lt;span class="comment"&gt;#$ rake run_task_1_using_dependencies&lt;/span&gt;
&lt;span class="comment"&gt;#=&amp;gt; to_be_run_before_task_1&lt;/span&gt;
&lt;span class="comment"&gt;#=&amp;gt; task_1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DeferredUntilInspirationHits?a=atudY4C"&gt;&lt;img src="http://feeds.feedburner.com/~f/DeferredUntilInspirationHits?i=atudY4C" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeferredUntilInspirationHits/~4/196168732" height="1" width="1"/&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=13367"&gt;</description><author>deferred until inspiration hits</author><pubDate>2007-12-06T00:00:00</pubDate><category>Ruby on Rails</category></item><item><title>Inject Ruby into any running OS X application</title><link>http://softlogger.com/12782/Ruby-on-Rails/inject-ruby-into-any-running-os-x-application.aspx</link><description>&lt;p&gt;&lt;img src="http://www.rubyinside.com/wp-content/uploads/2007/11/rinject.png" width="304" height="204"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://rubycocoa.sourceforge.net/RubyInject"&gt;RubyInject&lt;/a&gt; is an intriguing new tool that can "inject" a Ruby interpreter into any running OS X application. Why? Well, along with RubyCocoa it allows you to interact with an application "from the inside." If you're a RubyCocoa aficionado you can probably think of a few cute tricks to use this for already. If not, then just think about AppleScript on acid. All of this fun and games does require OS X 10.5 (Leopard), however.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://feeds.feedburner.com/~a/RubyInside?a=yyzPnW"&gt;&lt;img src="http://feeds.feedburner.com/~a/RubyInside?i=yyzPnW" border="0"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/RubyInside?a=cqxVunB"&gt;&lt;img src="http://feeds.feedburner.com/~f/RubyInside?i=cqxVunB" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/RubyInside?a=oNBWcPb"&gt;&lt;img src="http://feeds.feedburner.com/~f/RubyInside?i=oNBWcPb" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/RubyInside?a=2Xj8T2b"&gt;&lt;img src="http://feeds.feedburner.com/~f/RubyInside?i=2Xj8T2b" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/RubyInside/~4/191417632" height="1" width="1"/&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=12782"&gt;</description><author>Ruby Inside</author><pubDate>2007-11-27T00:00:00</pubDate><category>Ruby on Rails</category></item><item><title>Ruby 101: Naming Conventions</title><link>http://softlogger.com/8525/Ruby-on-Rails/ruby-101-naming-conventions.aspx</link><description>
            &lt;p&gt;&lt;span class="caps"&gt;UPDATE&lt;/span&gt;: Fixed some typos in the DialUpModem example code.&lt;/p&gt;


	&lt;p&gt;Ruby enforces certain coding conventions, while others are considered to be community-accepted idiomatic Ruby.  I’d like to cover them here.&lt;/p&gt;


	&lt;p&gt;I can’t cover everything in one blog post.  Instead, I’ll review the more egregious cases that seem to pop up on the Ruby and Rails mailing lists.  Most of these seem to come from our Java friends who are now using Ruby without regard to learning Ruby style.  .NET developers are prone to the same criminal activities, so I hope this will help both Java and .NET developers that are new to Rails.&lt;/p&gt;


	&lt;p&gt;Today all of these situations involve method names.&lt;/p&gt;


	&lt;h2&gt;lowercase_and_underscored&lt;/h2&gt;


	&lt;p&gt;Suppose we have a class &lt;code&gt;DialUpModem&lt;/code&gt; with a method that will terminate the connection.&lt;/p&gt;


	&lt;p&gt;Please don’t do this, you formerly-Java people:&lt;/p&gt;


&lt;pre&gt;&lt;code class="ruby"&gt;def hangUp()
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;nor this, formerly-.NET people:&lt;/p&gt;


&lt;pre&gt;&lt;code class="ruby"&gt;def HangUp()
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Instead, do this, all you seen-the-light-and-now-very-cool people:&lt;/p&gt;


&lt;pre&gt;&lt;code class="ruby"&gt;def hang_up
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Notice two things here:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;everything is in lowercase&lt;/li&gt;
		&lt;li&gt;underscores separate words&lt;/li&gt;
		&lt;li&gt;don’t append empty parentheses if there are no parameters&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Ok, that was three things, not two, just to see if you’re awake.&lt;/p&gt;


	&lt;h2&gt;Methods that return boolean values&lt;/h2&gt;


	&lt;p&gt;Don’t do this, formerly-Java people:&lt;/p&gt;


&lt;pre&gt;&lt;code class="ruby"&gt;def isOnline()
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;nor this, formerly-.NET people:&lt;/p&gt;


&lt;pre&gt;&lt;code class="ruby"&gt;def IsOnline()
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Instead, do this, all you seen-the-light-and-now-very-cool people:&lt;/p&gt;


&lt;pre&gt;&lt;code class="ruby"&gt;def online?
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;See?  We don’t use the word “is” to start a method name.  Instead, the Ruby language recommends that you use a question mark at the end of a method name to indicate that it will return a boolean value. (It’s not required by the language, it’s just a convention you should follow.)&lt;/p&gt;


	&lt;p&gt;By the way, you can still take parameters if you need to:&lt;/p&gt;


&lt;pre&gt;&lt;code class="ruby"&gt;def high_speed?(min_speed = 19200)
&lt;/code&gt;&lt;/pre&gt;

	&lt;h2&gt;Properties Are For Monopoly Players&lt;/h2&gt;


	&lt;p&gt;...not Ruby programmers.  So &lt;strong&gt;puleeeze&lt;/strong&gt; don’t do this:&lt;/p&gt;


&lt;pre&gt;&lt;code class="ruby"&gt;class DialUpModem

    def get_speed
      return @speed
    end

    def set_speed(value)
      @speed = value
    end

end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Don’t use getters and setters when there’s no logic involved.  Do this:&lt;/p&gt;


&lt;pre&gt;&lt;code class="ruby"&gt;class DialUpModem

    attr_accessor :speed

end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Done. Nice. Clean. Simple.&lt;/p&gt;


	&lt;p&gt;If you do have logic involved, you can still override the getter or setter as appropriate:&lt;/p&gt;


&lt;pre&gt;&lt;code class="ruby"&gt;class DialUpModem

    attr_accessor :speed

    def speed=(value)
      # Limit the speed to 19200 baud.
      if new_speed &amp;gt; 19200
        @speed = 19200
      else
        @speed = value
      end
    end

end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Notice the ’=’ sign at the end of the method name – that’s how you define a “setter” method in Ruby.&lt;/p&gt;


	&lt;h2&gt;If/Else Statements Are Suspicious&lt;/h2&gt;


	&lt;p&gt;I know I said this post was just about method names, but now that you’ve made it this far I can’t resist one more Ruby tip.&lt;/p&gt;


	&lt;p&gt;See that setter method we just wrote? That is some very, very ugly Ruby code.&lt;/p&gt;


	&lt;p&gt;Learn instead to wield the power of the Enumerable module:&lt;/p&gt;


&lt;pre&gt;&lt;code class="ruby"&gt;def speed=(value)
    @speed = [value, 19200].min
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;h2&gt;How to Learn Idiomatic Ruby&lt;/h2&gt;


	&lt;p&gt;Read the good Ruby books by the good authors: David A. Black, Dave Thomas, Hal Fulton, and others.  And read as much Ruby code as you can, so you can start to become assimilated into the Ruby style of programming.&lt;/p&gt;
          
&lt;p&gt;&lt;a href="http://feeds.feedburner.com/~a/SoftiesOnRails?a=OxOLFg"&gt;&lt;img src="http://feeds.feedburner.com/~a/SoftiesOnRails?i=OxOLFg" border="0"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/SoftiesOnRails?a=DhGiAcSG"&gt;&lt;img src="http://feeds.feedburner.com/~f/SoftiesOnRails?i=DhGiAcSG" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/SoftiesOnRails?a=HzpaosqX"&gt;&lt;img src="http://feeds.feedburner.com/~f/SoftiesOnRails?i=HzpaosqX" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/SoftiesOnRails?a=dlo5dbDi"&gt;&lt;img src="http://feeds.feedburner.com/~f/SoftiesOnRails?i=dlo5dbDi" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/SoftiesOnRails?a=WjMM93fm"&gt;&lt;img src="http://feeds.feedburner.com/~f/SoftiesOnRails?i=WjMM93fm" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/SoftiesOnRails/~4/171374544" height="1" width="1"/&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=8525"&gt;</description><author>Softies on Rails</author><pubDate>2007-10-24T00:00:00</pubDate><category>Ruby on Rails</category></item><item><title>Ruby's Hidden do {} while () Loop</title><link>http://softlogger.com/8963/Ruby-on-Rails/ruby-s-hidden-do--while--loop.aspx</link><description>I found the following snippet while reading the source for &lt;code&gt;Tempfile#initialize&lt;/code&gt; in the Ruby core library:
&lt;pre&gt;&lt;code&gt;
begin
  tmpname = File.join(tmpdir, make_tmpname(basename, n))
  lock = tmpname + '.lock'
  n += 1
end while @@cleanlist.include?(tmpname) or
  File.exist?(lock) or File.exist?(tmpname)
&lt;/code&gt;&lt;/pre&gt;

At first glance, I assumed the &lt;code&gt;while&lt;/code&gt; modifier would be evaluated before the contents of &lt;code&gt;begin...end&lt;/code&gt;, but that is not the case. Observe:
&lt;pre&gt;&lt;code&gt;
&amp;gt;&amp;gt; begin
?&amp;gt;   puts "do {} while ()" 
&amp;gt;&amp;gt; end while false
do {} while ()
=&amp;gt; nil
&lt;/code&gt;&lt;/pre&gt;
As you would expect, the loop will continue to execute while the modifier is true.
&lt;pre&gt;&lt;code&gt;
&amp;gt;&amp;gt; n = 3
=&amp;gt; 3
&amp;gt;&amp;gt; begin
?&amp;gt;   puts n
&amp;gt;&amp;gt;   n -= 1
&amp;gt;&amp;gt; end while n &amp;gt; 0
3
2
1
=&amp;gt; nil
&lt;/code&gt;&lt;/pre&gt;

While I would be happy to never see this idiom again, &lt;code&gt;begin...end&lt;/code&gt; is quite powerful. The following is a common idiom to memoize a one-liner method with no params:
&lt;pre&gt;&lt;code&gt;
def expensive
  @expensive ||= 2 + 2
end
&lt;/code&gt;&lt;/pre&gt;
Here is an ugly, but quick way to memoize something more complex:
&lt;pre&gt;&lt;code&gt;
def expensive
  @expensive ||=
    begin
      n = 99
      buf = " " 
      begin
        buf &amp;lt;&amp;lt; "#{n} bottles of beer on the wall\n" 
        # ...
        n -= 1
      end while n &amp;gt; 0
      buf &amp;lt;&amp;lt; "no more bottles of beer" 
    end
end
&lt;/code&gt;&lt;/pre&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=8963"&gt;</description><author>jvoorhis</author><pubDate>2007-10-24T00:00:00</pubDate><category>Ruby on Rails</category></item><item><title>What's New in Edge Rails: Better Exception Handling</title><link>http://softlogger.com/9044/Ruby-on-Rails/what-s-new-in-edge-rails-better-exception-handling.aspx</link><description>
            &lt;p&gt;It’s a common pattern to redirect the user to, or render specific pages for different types of exceptions that are thrown in your application.  Prior to this &lt;a href="http://dev.rubyonrails.org/changeset/7597"&gt;changeset&lt;/a&gt; this usually involved overloading the &lt;code&gt;rescue_action_in_public&lt;/code&gt; method of your controllers:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&lt;span class="r"&gt;class&lt;/span&gt; &lt;span class="cl"&gt;PostsController&lt;/span&gt; &amp;lt; &lt;span class="co"&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;def&lt;/span&gt; &lt;span class="fu"&gt;rescue_action_in_public&lt;/span&gt;(exception)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;case&lt;/span&gt;(exception)&lt;tt&gt;
&lt;/tt&gt;      &lt;span class="r"&gt;when&lt;/span&gt; &lt;span class="co"&gt;ActiveRecord&lt;/span&gt;::&lt;span class="co"&gt;RecordNotFound&lt;/span&gt; &lt;span class="r"&gt;then&lt;/span&gt; render &lt;span class="sy"&gt;:file&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;/bad_record&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class="r"&gt;when&lt;/span&gt; &lt;span class="co"&gt;NoMethodError&lt;/span&gt; &lt;span class="r"&gt;then&lt;/span&gt; render &lt;span class="sy"&gt;:file&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;/no_method&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class="r"&gt;else&lt;/span&gt; render &lt;span class="sy"&gt;:file&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;/error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="r"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;It’s easy to see that this can quickly grow to be an ugly mass of a &lt;code&gt;case&lt;/code&gt; or &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt; statement.&lt;/p&gt;


	&lt;p&gt;Now we’ve got a much cleaner way to map exceptions to handlers with the new &lt;code&gt;rescue_from&lt;/code&gt; support.  &lt;code&gt;rescue_from&lt;/code&gt; maps an exception type directly to a handler method name for a very concise and direct way of dealing with exceptions:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&lt;span class="r"&gt;class&lt;/span&gt; &lt;span class="cl"&gt;PostsController&lt;/span&gt; &amp;lt; &lt;span class="co"&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="c"&gt;# Declare exception to handler methods&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  rescue_from &lt;span class="co"&gt;ActiveRecord&lt;/span&gt;::&lt;span class="co"&gt;RecordNotFound&lt;/span&gt;, &lt;span class="sy"&gt;:with&lt;/span&gt; =&amp;gt; &lt;span class="sy"&gt;:bad_record&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  rescue_from &lt;span class="co"&gt;NoMethodError&lt;/span&gt;, &lt;span class="sy"&gt;:with&lt;/span&gt; =&amp;gt; &lt;span class="sy"&gt;:show_error&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;def&lt;/span&gt; &lt;span class="fu"&gt;bad_record&lt;/span&gt;; render &lt;span class="sy"&gt;:file&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;/bad_record&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;; &lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;def&lt;/span&gt; &lt;span class="fu"&gt;show_error&lt;/span&gt;(exception); render &lt;span class="sy"&gt;:text&lt;/span&gt; =&amp;gt; exception.message; &lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="r"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Note that the exception handler methods can be either no-arg methods or take the exception in question as an argument (as in &lt;code&gt;show_error&lt;/code&gt; above).&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://dev.rubyonrails.org/changeset/7822"&gt;You can also&lt;/a&gt; use a block or proc to specify exception handling in &lt;code&gt;rescue_from&lt;/code&gt;:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&lt;span class="r"&gt;class&lt;/span&gt; &lt;span class="cl"&gt;PostsController&lt;/span&gt; &amp;lt; &lt;span class="co"&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="c"&gt;# Declare exception to handler methods&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  rescue_from(&lt;span class="co"&gt;ActiveRecord&lt;/span&gt;::&lt;span class="co"&gt;RecordNotFound&lt;/span&gt;) { |e| render &lt;span class="sy"&gt;:file&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;/bad_record&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;  rescue_from &lt;span class="co"&gt;NoMethodError&lt;/span&gt;, &lt;span class="sy"&gt;:with&lt;/span&gt; =&amp;gt; proc { |e| render &lt;span class="sy"&gt;:text&lt;/span&gt; =&amp;gt; e.message }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="r"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;tags: &lt;a href="http://technorati.com/tag/ruby"&gt;ruby&lt;/a&gt;,
&lt;a href="http://technorati.com/tag/rubyonrails"&gt;rubyonrails&lt;/a&gt;&lt;/p&gt;
          
&lt;p&gt;&lt;a href="http://feeds.feedburner.com/~a/RyansScraps?a=TWuJ7V"&gt;&lt;img src="http://feeds.feedburner.com/~a/RyansScraps?i=TWuJ7V" border="0"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/RyansScraps?a=N33xngxm"&gt;&lt;img src="http://feeds.feedburner.com/~f/RyansScraps?i=N33xngxm" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/RyansScraps?a=URwrDUkj"&gt;&lt;img src="http://feeds.feedburner.com/~f/RyansScraps?i=URwrDUkj" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/RyansScraps?a=ZPRatS79"&gt;&lt;img src="http://feeds.feedburner.com/~f/RyansScraps?i=ZPRatS79" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/RyansScraps?a=nz83UFJ2"&gt;&lt;img src="http://feeds.feedburner.com/~f/RyansScraps?i=nz83UFJ2" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=9044"&gt;</description><author>Ryans Scraps</author><pubDate>2007-10-24T00:00:00</pubDate><category>Ruby on Rails</category></item><item><title>Interesting Ruby Tidbits That Don't Need Separate Posts #6</title><link>http://softlogger.com/9271/Ruby-on-Rails/interesting-ruby-tidbits-that-don-t-need-separate-posts-6.aspx</link><description>&lt;p&gt;&lt;strong&gt;Reading Excel Files From Ruby&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We Heart Code posts &lt;a href="http://www.weheartcode.com/2007/10/05/reading-an-excel-file-with-ruby"&gt;a tutorial&lt;/a&gt; showing how to use the &lt;em&gt;&lt;a href="http://raa.ruby-lang.org/project/parseexcel/"&gt;Parseexcel&lt;/a&gt;&lt;/em&gt;&lt;em&gt; &lt;/em&gt;library, a port of a Perl library that lets you parse Excel spreadsheets from your code.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How To Debug Your Rails App With ruby-debug&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Patrick Lenz presents &lt;a href="http://www.sitepoint.com/article/debug-rails-app-ruby-debug"&gt;a great article that shows how to debug a Rails application&lt;/a&gt; from start to finish.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Economical Use of Amazon S3 with Ruby on Rails&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Robert Dempsey has written a comprehensive article on &lt;a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=955"&gt;how to use S3 in an economic, efficient way&lt;/a&gt; from Ruby on Rails applications.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Ruby on Rails vs ColdFusion Commercial&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ever active RailsEnvy guys have produced their &lt;em&gt;eighth&lt;/em&gt; Ruby on Rails vs X commercial.. presenting &lt;a href="http://www.railsenvy.com/2007/10/3/ruby-on-rails-vs-coldfusion"&gt;Ruby on Rails vs ColdFusion&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;&lt;a href="http://feeds.feedburner.com/~a/RubyInside?a=pBTKJ5"&gt;&lt;img src="http://feeds.feedburner.com/~a/RubyInside?i=pBTKJ5" border="0"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/RubyInside?a=btFkamQy"&gt;&lt;img src="http://feeds.feedburner.com/~f/RubyInside?i=btFkamQy" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/RubyInside?a=d5T652Tp"&gt;&lt;img src="http://feeds.feedburner.com/~f/RubyInside?i=d5T652Tp" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/RubyInside?a=7Rwg3rFB"&gt;&lt;img src="http://feeds.feedburner.com/~f/RubyInside?i=7Rwg3rFB" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/RubyInside/~4/170882871" height="1" width="1"/&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=9271"&gt;</description><author>Ruby Inside</author><pubDate>2007-10-17T00:00:00</pubDate><category>Ruby on Rails</category></item></channel></rss>