Preparing for Rails 2.0

Anyone that has used Rails 1.2.3, 1.2.4 or 1.2.5 may have noticed a number of deprecation notices in their development logs. Whilst these deprecated methods still work as expected in 1.2.x versions, you will come-a-cropper when you try to upgrade to Rails 2.0. So what do you need to do and what tools are out there to help you with the move? Glad you asked.

The first thing you can do it run your code through a code checker — Geoffrey Grosenbach has released a great rake task which digs through your code looking for the old methods. It will give you hints of how to fix the issues, but lets look at them a little more closely.

@params, @session, @flash, @env

As of Rails 2.0, you won’t be able to directly access the above instance variables. They have been replaced with methods, which makes customising their actions much easier. It also allows the internals of Rails to change without breaking the API. This is very easy to fix – just remove the @ in front of those variables – they will work exactly the same.

find_all, find_first, render_partial

In earlier version of Rails there were a number of grouped methods, that do very similar things – find, find_all and find_first all fetch records from the database, the only difference is the number of records they return. It was decided to combine these methods in to one where they are differentiated by passed in options. So find_all becomes find(:all) and find_first becomes find(:first) and render_partial becomes render(:partial).


Out of all the HTML helpers, the form tag was an anomaly because it required a start AND end helper. To make it fit in with way the rest of Rails works and to facilitate dynamic form generation, a block method called form_tag was created. This particular update has a trap in it through – because blocks don’t return values, the ERB tag you use must not have an = sign, so

     <%= start_form_tag %>        <!-- Form stuff -->    <%= end_form_tag %> 


      <% form_tag do %>         <!-- Form stuff -->     <% end %> 

Notice the omission of the equals sign in the latter example?

Also note that passing :post => %gt; true is deprecated. With the push for RESTfulness, the form needs to know about the other HTTP verbs, put and delete, so a new option has been created:

      <% form_tag :method => :post do %>         <!-- Form stuff -->     <% end %> 


A number of what used to be core components of rails have been moved out into plug-ins so as not to clutter the core with stuff that you don’t use very often. It also means that the development of the plugins can be much quicker than that of the core. Probably the major extraction is the third-party database interfaces. Now, by default only MySQL, SQLite and PostgreSQL are supported out of the box. All other databases are supported via gems named activerecord-database-adapter. If you want to use an Oracle just run

gem activerecord-oracle-adapter

and you will be peachy again.

Other extractions of note are the acts_as plug-ins. If you use acts_as_tree or acts_as_list in your model, you will need to script/plugin install them and the built-in pagination has now become the classic_pagination plug-in. Note that by the developers own admission that plug-in is slow (and was slow when it was in core), so if you use it, you may want to think about migrating across to the new and improved will_paginate plug-in.

So hop to it and get your web apps upgraded now before the rush!


Category: programming Time: 2007-10-31 Views: 2

Related post

  • Preparing for Rails 2.0: Controller-based exception handling 2007-11-07

    Since Ruby is a pure Object-Oriented Language, exceptions play a big role in the flow of control. Previously, you had the choice of rescuing exceptions at a local level or you could override the rescue_action method in your controller. The former met

  • Ubuntu desktop through pen drive for rails development 2010-06-25

    I am window user and .net web developer. I am trying hands in ruby and "ruby on rails". Everybody suggests me to use OSx or Linux. Can i install Ubuntu on "pen drive" and use as development machine for the same. If yes please let me kn

  • Get Your App Ready for Rails 4 2013-01-01

    A new Rails version is about to be released and it's coming with many changes, deprecations, and new features. Lets take a look at what you need to do to get your app ready for Rails 4. The Path to Upgrade The easiest way to be ready for Rails 4 is h

  • The Web Design Business Kit Chapter 13 - Prepare For Expansion 2003-07-20

    In this chapter, we'll start to discuss the logistics of expanding your business. We'll discuss what it takes to move your business forward, and the all-important systems you'll need to have in place in order to grow. You'll learn why your technical

  • Preparing for Semantic Web Services 2004-05-02

    The inventor of the World Wide Web, Tim Berners-Lee, is also the originator of the next generation of Web architecture, the Semantic Web. Currently, his World Wide Web consortium (W3C) team works to develop, extend, and standardize the Web's markup l

  • What should a hosting company do to prepare for IPv6? 2010-05-17

    At the time of writing The IPv4 Depletion Site estimates there are 300 days remaining before all IPv4 addresses have been allocated. I've been following the depletion of IPv4 addresses for some time and realize the "crisis" has been going on for

  • How to prepare for a game development competition? 2010-08-03

    Ludum Dare 18 is coming up and I'll be participating in it. I've done a couple other short-term game competitions in the past but this is my first big one (and my first solo one). I am REALLY excited for it, but I'm wondering if there are any tricks

  • How can I tell if a QuickTime movie is prepared for streaming? 2011-02-14

    I have been given a QuickTime file to place on a web site for my client. I requested the file be prepared for streaming using "Fast Start - Compressed Header" so that the video with start to play as soon as QuickTime player has buffered enough.

  • Which Red Hat version i need to prepare for red hat exams? 2011-03-07

    Which Red Hat version i need to prepare for red hat exams? (maybe centos anough ) Thanks --------------Solutions------------- There was a brief changeover period where RHEL5 exams were still being taken but all courses and exams should now be happeni

  • Problem: To make default mongrel web server for rail 3.0 2011-03-08

    Solution : You have only one ruby version of ruby 1.9.2p180 (2011-02-18) [i386-mingw32] Problem Cause: Registry is still showing older version of RubyGems Solution Path: Remove all old version of ruby & dependencies (Note ensure to have all the back

  • Preparation for Ph.D 2011-04-22

    I am going to start Ph.D (software security research) very soon. How can I prepare for that. Please recommend any tools or softwares that I need to familiarize with before stating the Ph.D. Any advices other than softwares? --------------Solutions---

  • Preparing for Interviews 2011-05-29

    Possible Duplicate: How to prepare yourself for programming interview questions? Could someone give me pointers on how go to about preparing for a technical interview? As a CS graduate, I guess one must be thorough with the following topics: Data Str

  • How should a programmer prepare for a new job? 2011-06-04

    I have just graduated from college and have about 2 months time before I start working at the company. I have experience in C, C++, Java and a bit of Android (developed an app last summer, stopped working on that later). I just want to learn somethin

  • How to prepare for protecting identity after death? 2011-06-07

    In the context of online accounts and identities, what are some best practices to prepare for the one certainty we all face: not a one of us will get out alive. --------------Solutions------------- The certainty of ultimate demise, be it biological o

  • Windows XP SP3 - Freezes at "Preparing for Hibernate" (or StandBy) caused by Bluetooth driver 2011-06-29

    Dell Lattitude E6410, 4GB ram, Windows XP SP3. I've had it for about 6 months, it has been very well behaved, no unexpected problems to speak off. Then suddenly, in the last three days, it froze twice on "Preparing to Standby" and then yesterday

  • What is the best book to prepare for a Java interview? 2011-10-18

    Possible Duplicate: How to prepare yourself for programming interview questions? I found older questions but I was wondering if newer, better books/guides have been published in the last two years. I am interviewing for a technology analyst position

  • Preparing for algorithm-related interview questions 2011-11-07

    So, I've just realized that some employers may ask an interview question that is relative to some complex mathematical algorithm. It seems like answering these questions is a skill in its own right. After all, I'm quite good at developing algorithms

  • would preparing for CCNA add "significantly" to my knowledge as a penetration tester? 2011-11-10

    I'm a post graduate student and self taught programmer. I concentrated on Computer Networks & Operating Systems more during my undergraduate studies. I can explain usually used protocols by sniffing the traffic on wires. Operating Systems was my obse

  • Twitter Bootstrap, Less, and Sass: Understanding Your Options for Rails 3.1 2011-11-16

    Twitter Bootstrap and Rails Twitter Bootstrap, Less, and Sass: Understanding Your Options for Rails 3.1 Too good to be true! Twitter Bootstrap meets Formtastic and Tabulous How to Customize Twitter Bootstrap's Design in a Rails app By now, we've all

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 1.415 (s). 13 q(s)