Thursday, May 21, 2009

Updating a Rails Project 1.2.0 -> 2.3.2

I have a project that's been stable and in production for some time, but I now want to add some features to and 'modernize' a bit. Because it's been stable there's been no need to keep up with Rails as it's progressed, but now that I'm looking to add on, I'd like to use some of the new Rails goodness. So what I've chronicled here is what I needed to do to move a project from Rails 1.2.0 to 2.3.2.

There is nothing special about the application, it's basically a lot of CRUD in an admin interface, a simple signup/registration page, some photo galleries and a mass mailer; it's for a night club promoter.

When I developed this, I pinned a revision number of the edge svn repository as an external dependency in my local svn, as Rails moved to Git some time ago, this was the first thing that needed to be addressed. I also would be moving from a Apache mod_proxy/Mongrel deployment to a Phusion Passenger deployment, so my current Capistrano deploy.rb file was basically worthless. After a little thinking about approach, I just decided to bite the bullet and start a new Rails 2.3.2 project under Git and migrate the codebase.

So after doing a little Git housekeeping (mostly setting up the .gitignore file), I copied over the /app directory, my config/routes.rb and my contributions to /public and ran rake db:migrate. Then the moment of truth, running script/server; drum roll please -- the app booted fine! I was truely surprised.

After my inital shock though, I started clicking and then things started breaking -- which I expected. First up, none of my filters were working, in fact any call to them promplty crashed the app. Low and behold, application.rb is now called application_controller.rb ... copy and paste my filters, delete my application.rb file, woo hoo, I can get to admin now!

Next up, complaints that method paginate is not found. Hmm, a little googling tells me that's because pagination has been removed from rails core. A little more searching and I found myself installing the will_paginate plugin and editing about 6 controller/view pairs updating the syntax.

The bombs keep on coming, now auto complete methods are failing ... again a removal from rails core and the auto_complete plugin come to the rescue; this time with no syntax changes.

Onto playing with the CRUD ... Oops, have some deprecated/discontinued start_form_tag / end_form_tag constructs. 3 more views edited.

Photos are a big part of this site, both in the current news for the front page as flyers and in the galleries showing in situ shots of folks at events. I originally developed using the file_column plugin. I'd already made a mental note that 'phase II' of this conversion would be to swap out file_column for attachment_fu because file_column is no longer under development, but I really didn't want to combine that project now. When I when to test the image functionality I feared I might have to, loading an image page threw as file_column error about a bad call to an Inflector method. Again Google to the rescue; seems Active Support has had some changes and I needed to patch the plugin. Fortunately, others have blazed this trail before and I found what I needed, an explicit namespace call to ActiveSupport::Inflector (found here).

After all those gyrations, the only thing left to do was fix Capistrano and my deployment recipe. This also turned out to be quite simple, change the :scm to :git, point at repository and execute a 'touch' command to tmp/restart.txt instead of my mongrel_cluster command.

Lot's of nits, no real pain in this migration. All for now.

Thursday, October 9, 2008

DVD Audio to MP3

So it seems in looking at my last attempt at blogging that the only post I really wanted to save was this one ... how to rip a DVD soundtrack to MP3 ... here it is:

I’d wondered how to do this for a while. I have a bunch of concert DVDs that I wanted to listen to while traveling or in the car, but how get the audio wasn’t self evident. I finally got around to spending some quality time with google to find the answer, so I document it here both for my own future recollection and in case the google gods send you to this page first :)

In essence you create a fifo pipe and then use mplayer to send the sound in raw pcm to the pipe while using a null video codec … that looks like this:

mkfifo soundpipe

lame -b 128 soundpipe your_new.mp3 &

mplayer -quiet -ao pcm -aofile soundpipe -vo null -vc dummy -aid 128 dvd://2

First command makes the pipe, second starts the lame encoder and the third starts playback. Works great! Only small hiccup I had was that newer versions of mplayer wanted the options in the form of -ao pcm:file=soundpipe depracating the -aofile.

I found this basic technique in 2 places:

http://gigo.com/archives/Blog/dvd_to_mp3_and_ipod.html
http://www.perturb.org/content/dvd2mp3-2.html

Right tool for the job ...

I've tried doing a blog for a long time. Fits and starts abound, but at the core I was always futzing with the 'engine' ... phpNuke, Wordpress, home grown, whatever. So I finally got around to just using a blog engine .. this one!

Goes along with bringing myself into this decade ... opened a facebook account, linkedin, twitter ... it remains if I actually can/will continue using them, but I must say that at least with respect to the sites mentioned above, I like the 'social' aspects a whole lot more than I thought I would ... I certainly knew of those sites for a while, what they did ... just thought it was a gimmick, not something useful.

Guess old dogs can learn new tricks!