21 December 2007

Rails - error with rake rails:freeze:gems

After upgrading to Leopard with Rails 1.2.6, I was getting this error when I tried to freeze rails:


$ rake rails:freeze:gems
(in /Users/harold/rails/activist)
rake aborted!
no such file to load -- /Users/harold/rails/activist/config/../vendor/rails/railties/lib/initializer
/Users/harold/rails/activist/rakefile:4
(See full trace by running task with --trace)


My solution was to use rake rails:freeze:edge like so:


rake rails:freeze:edge TAG=rel_1-2-6

12 October 2007

New "Draft" Gore 2008 website - See-Al-run.com

Building the See Al run website

I've had this idea floating around in my head for a while. My wife and I both feel very strongly that Al Gore should be running for President... well, actually, that he should be President.

Since this is a more-or-less technically focused blog, I'm not getting into politics here. But I had this idea for a website as a way to encourage support for Al Gore to run.

There are plenty of "draft Gore" type websites out there - blogs, petitions, and general information accumulation sites.

I was intrigued by the simple brilliance of the human element captured by Sorry Everybody after the 2004 election. People take pictures of themselves holding hand-written messages and submit them to the website. Visitors to the site get to browse through the photos. Some are very clever.

So, I wanted to do something similar, albeit with a more positive message. I wanted people to submit photos of themselves asking Al Gore to jump into the race for 2008. I was running out of time because I knew the Nobel Peace Prize announcement was coming up and I wanted to have the site live by then.

I've been swamped with work and other free-lance website projects lately and just never got a break to do it. But then in the last week I got to a stopping point on a project. Then the question was could I pull it off in a week? Build a site from scratch with uploads, tagging, moderator accounts, image manipulation...? In my spare time outside of my 40 hour work week? What the hell - I went for it.

I think I've said this before but it's worth saying again. Ruby on Rails rocks. I coded in PHP for a while and I could never have knocked this project out in anywhere close the amount of time I did it in Rails. But, much of the credit goes to those who create and maintain some of the great Rails plugins.

So, I met my goal. With the help of my wife with testing and content, we went live with the site Thursday night, just in time for the Nobel announcement. In all honesty I don't know that the timing made any difference since I'm still struggling to get people to the site, but it was a good challenge, and I'm happy with it.

Check it out. Post a picture asking Al Gore to run for President in the 2008 election.

01 April 2007

Converting legacy php database to Rails

I've been working on converting an old php application to Ruby on Rails. Several months ago during the development process, I wrote some scripts to take the data from the old database and insert it into the new one, performing any necessary adjustments to the data that was needed. I ran into a problem when I needed to do it again recently in preparation for the move into production because I couldn't remember how I did it the first time. So, here it is:

I used the script outline talked about here: Rewriting a (large) PHP application in Rails, part 1

The database_configuration["old_production"] in the example is pointing to a database connection named "old_production" in the database.yml file.

I saved the script in /lib under my rails app root directory, and to run it use:

../script/runner 'load "my_conversions_script.rb"'



22 March 2007

Rerouting old style PHP query string urls to a Rails app

I've re-written an old php application in Ruby on Rails. In anticipation of flipping the switch from the old site to the new one, it would be nice to re-route requests for the old php pages to their new home.

The old page url would look something like this:

/page.php?pageid=mypage

with the new equivalent being this:

/page/mypage

I wasn't sure if the best place to handle the rerouting would be the rails routes.rb file, or using mod_rewrite in the .htaccess file.

I didn't find a way to do it using routes.rb, so here's the solution I came up with to make it work using .htaccess:

RewriteCond %{QUERY_STRING} ^pageid=(.*)$
RewriteRule ^page\.php /page/%1? [R=301,L]

I added the two lines after the original "RewriteRule ^$ index.html [QSA]" line.

I found all kinds of information about doing the opposite - i.e. rewriting /page/pageid/mypage to redirect to page.php?pageid=mypage. I had to sift through all that to find what I needed.

13 March 2007

Sony Ericcson w300i on Mac OS X

I've been using a Sony Ericsson w300i Walkman phone since Cingular first offered it. I chose the phone not really for the Walkman capabilities, but because I was looking for a phone that I could use to replace most of the functions that my old Palm/Handspring Visor was used for.

Mostly, my Visor was used for the address book, memo pad notes, and calendar. It was getting old, and since I converted from Windows to Mac and bought a Powerbook I ran into the problem of not having compatible Sync software that would recognize the Visor and work with OS X. Ideally, I could replace the Visor with a phone and only carry one device. But, I also didn't want to spend all the money on a smartphone or Treo.

Lots of phones have decent address books. But I also wanted a decent calendar, and really important was the ability to copy text notes between my Mac and the phone. Adequate memory was also a concern, so the ideal phone would have expandable memory.

I wasn't sure the w300i would meet the text note requirement, but I gambled on it and bought it. After purchasing a third party phone plugin for iSync, it worked flawlessly. I bought a 512MB memory card for it, and it really is a great phone. The organizer tools are excellent - the address book and calendar are perfect for what I need. And using bluetooth or the data cable, I can transfer files between the phone and Mac as needed. It has a built-in web browser that is used to open text files.

It also has the other neat features like the Walkman, and even an FM radio, but I have to admit I haven't really used those. The built-in camera isn't great, and the video captures are pretty low quality. But, that's okay - it does what I need. It's a good looking phone, too.

Now, if only Cingular didn't disable other cool features, I'd be totally happy. Greed gets the best of these big companies and they just have to try to squeeze every last penny out of you at the expense of customer satisfaction. But, I'll save that for another post...

07 March 2007

vpnc vs. Cisco's vpnclient on Fedora

After breaking Cisco's vpnclient AGAIN by upgrading to Fedora Core 6, and starting to go through the headache of trying to get it to compile, I poked around a bit to look for alternatives. Voila! I found vpnc, installed it, and had it up and running in no time.

Of course I'm just using the default configuration for now until I have time to try out some advanced configuration and scripting, and maybe the GUI.

Anyhow, good riddance to the terrible Cisco client for Linux.

11 January 2007

Capistrano deploy + Subversion version

Sometimes the mirrors aren't in alignment. Last night was one of those nights for me, and when I can't get something to work (the way I want it to) I tend to dig in my heels and keep pushing. Sometimes that just makes things worse.

I'm working on my first time using Capistrano to deploy a rails app. I have my app in a Subversion repository on my Linux server but I'm working from my Mac Powerbook. I'm walking through the instructions in both the Agile Web Development with Rails book, and the Capistrano manual on the RoR website.

Straightforward enough, once I get my rake/cap commands correct. I get down to the "cap deploy" step and get this error:

$ cap deploy
* executing task deploy
* executing task update
** transaction: start
* executing task update_code
* querying latest revision...
svn: invalid option: --limit
Type 'svn help' for usage.
*** [update_code] transaction: rollback
* [update_code] rolling back


Ok, at this point I have no way to know what svn command the script was trying to execute because it's all behind-the-scenes magic. There's probably a way to find out but I'm too new at this to know. So, Google to the rescue - I find this:

svn log --limit is in 1.2.x, not 1.1.x, so you need to have a 1.2.x

My server has a higher version than 1.2.x, but the client on my laptop is running the 1.1.x client. No problem, I installed it using fink, I'll just update it. No matter what I tried, fink and apt-get told me that I had the most up-to-date version, even though the fink website tells me the stable package is 1.4 something. I tried to get fink to update it's own binary version - wouldn't do it. So, I follow the instructions on the fink site to update from source. Huge mistake. It took f o r e v e r. Fink is now up-to-date on my laptop, but it still wouldn't update svn-client. Whatever. Why did I waste my time like this? Write it off as a learning experience...

So, I used fink to remove svn-client, and downloaded the binary linked on the subversion website. Problem solved.

I guess in this fast-paced web-dev world I need to keep my packages all up-to-date. Sometimes.

10 January 2007

Capistrano show_deploy_tasks

Ok - Ruby on Rails is way cool. And now I'm trying out a deployment for the first time using Capistrano.

The problem I'm finding with all of this is that I'm chasing a moving target and the documentation can't even keep up. Here are a couple of examples:

The documentation told me that I could get a list of deployment tasks and their descriptions by typing "rake show_deploy_tasks". Wrong:

$ rake show_deploy_tasks
rake aborted!
Don't know how to build task 'show_deploy_tasks'


The new command is "cap show_tasks".

Also, the "rake remote:setup" command is deprecated. Use "cap setup" instead.

Really, it's pretty crazy. I'm using the latest Agile book and reading the Cap manual from the Rails site.