Subversion 1.4.4 upgrade
Adam had recently got a MacBookPro. We no longer have to mess with InstantRails on Windows. It also means he can use native Subversion and SVK. However, the OSX-native package uses Subversion 1.4. Our servers uses Subversion 1.3.x. To be fully compatible, that would mean compiling a custom copy of Subversion 1.3.
After reading about the feature additions for Subversion 1.4, I decided it would be much easier for me to upgrade the server and my dev laptop to 1.4. Gentoo masks 1.4.4, but most Subversion upgrades are fairly transparent. There are two main benefits from the upgrade I wanted. Subversion 1.4 claims to be better at storing and transmitting binary data. We version a lot of raw data, so this would work out well. Subversion 1.4 also has a svnsync command that works like SVK's svn mirroring. It lets you move or clone a repository. Maybe Linus Torvald's acerbic comments about Subversion has been getting noticed.
Upgrading to Subversion 1.4 on Gentoo is a piece of cake. You add:
echo "=dev-util/subversion-1.4.4-r3" >> /etc/portage/package.keywords
and then
emerge =dev-util/subversion-1.4.4-r3
You can run revdep-rebuild to make sure all the library references are working, but I found that this was not necessary, even with the SVK installed. (With the perl use-flag set on Subversion, all the Perl bindings gets automatically updated on the system.)
To take advantage of the more-efficient binary storage, all the repositories needed to be upgraded. I shut down Apache to prevent anyone from making commits, backed up my repository, and moved the repository to a different directory while I setup the new repository directories. I then wrote two quick-and-dirty shell scripts to do this:
#!/bin/sh
mkdir tmp_dumps
for repo in `ls repos-1.3.x`; do
svnadmin dump repos-1.3.x/${repo} > tmp_dumps/${i}
done
and
#!/bin/sh
for repo in `ls tmp_dumps`; do
svnadmin create --fs-type fsfs repos/${repo}
svnadmin load repos/${repo} < tmp_dumps/${repo}
done
Note the --fs-type fsfs flag. You will have to change that if you are using the BerkeleyDB storage engine. These two scripts essentially creates a dump of all the repositories found in repos directory, then reloads them. During the reload, Subversion 1.4's svnadmin create command creates a new repository. The newly reloaded repository uses the more efficient binary storage scheme.
Lastly, I upgraded all of my local working copies. Subversion does this transparently, but I have a number of large repositories I use often. A simple svn update on each of the working copies upgrades the working copy to 1.4. Some of them take ten minutes to upgrade -- I do this now so I don't have to wait, later on.
Ho-Sheng Hsiao
Isshen, LLC
Gotcha: Defining a controller action called 'process'
Early in the morning on #rubyonrails, someone came into channel asking for help. He said that, inexplicably, on controller out of his several controllers stopped functioning. When asked for a log, he gave this pastie.
This is very puzzling. I even looked at the code around line 330 in ActionController:base
327 class << self
328 # Factory for the standard create, process loop where the controller is discarded after processing.
329 def process(request, response) #:nodoc:
330 new.process(request, response)
331 end
When asked about what his controller looked like, he gave this pastie.
Can you spot the error?
The Gotcha
As commented in ActionController::base, a new instance of the controller is generated and the method process is called. Unfortunately, all actions are also method definitions. By attempting to define an action called 'process', it overwrote the original process. That explained the error with the "Wrong number of arguments."
The Judgment
Don't name your action 'process'. And more importantly, dig into the code when you get weird errors like this.
-HoshRails BugTracker
I just cracked open a Rails Bug Tracker. The screenshots look good, and the project looks mature. I've been shopping for a native Rails bug tracker for use with our company, Isshen, LLC. This project looks like something I can quickly install and start using, despite its status as "Beta" on Rubyforge.
Suspicion first filled me when I saw that the project had a "Win32 source" download. That does not make any sense. A Rails app is fairly OS-agnostic. The download is distributed in a zip file. When opened, the source itself is packaged as a RAR. And there was a database.sql schema.
The schema was bad. It looked like something I would have written before I encountered Rails. There were three migration scripts in the Rails source. There was one that says "create_object". Huh?
Curious, I opened up app/model. No dice. There were three models ... and a file called mysqlconnection.rb. Why would a Rails app need that for? I got real suspicious.
And this suspicion was confirmed when I looked at the controllers. Each controller action would create a new mysqlconnection, generate the SQL query on the fly, and then render the template.
Essentially, the Rails Bug Tracker is a superficial port of a PHP program. And that PHP program wasn't even written using MVC architecture.
Wow.
Friends in business
My good friend James Hill, owner of Libre Systems, Ltd. in Manchester, UK sent me this article about his recently-established, growing Taxi Academy. He started this with Kashef Ahmed when they discovered the shortage of taxi drivers. At the time, James was working on a related startup idea -- that's another story to tell.
Contrary to what the article says, James doesn't actually drive a cab. His day job involves working as a system admin for a Manchester ISP. From across the Atlantic, we more or less egged each other on to form our startups. Like a number of other entrepreneurs, we didn't actually get to where we had set out to go. We meandered -- going through partners, products, and services. Seeing your friends grow keeps you on your toes -- you congratulate them and share in their success, while at the same time moving forward with your own plans so that you won't embarrass yourself in front of your peer.
About a month ago, he has asked me to help him complete an internal CRM for his Taxi Academy. He wanted it done in Rails, and got stuck on a particularly hard has_and_belongs_to_many join. In retrospect, I could have used a has_many :through association. while it is not much to look at, I wrote it in about three days.
I also got a ping from my local friends, UG Wilson and Travis Warlick of Operis Systems, LLC about Ruby Rock Stars. And from there, a short hop to RentACoder where I started picking up projects -- including the about-to-be completed modification to Typo called Flouzo.
A year and a half ago, I discovered Paul Graham's seed funder, YCombinator. I devoured his writings. I've since stumbled across people who severely disagree with his opinions, though I don't think they are people who have sold a company for $49 million. Paul Graham places a great deal of weight on who is founding the company with you, and where you are located. If the environment is saturated with startups, you're much more likely remember why you even tried at all, as you stare into the LCD screen full of code with grit-filled, hyper-caffeinated, severely-dehydrated eyes at 4 in the morning. It is for that, I'm grateful for my friends in business.
Useful tricks with script/console
One of my favorite tools for Rails is script/console. It lets me test out snippets of code to make sure things work the way they are supposed to work. I found two useful things this morning:
Tab completion
Tab completion works in script/console.
script/console
user = User.find :first
user.up[tab]
You have no idea how happy that makes me.
reload!
After I found out about tab completion, I found myself making some heavy code changes, and testing them out in the console. I kept having to quit and restart the console. Out on a lark, I hit 'r' and hit tab ... and found 'reload!'. I always wanted that command, but I had thought it was 'reload' not 'reload!'. Go figure.