Archive for the ‘rails’ Category

RadRails and Windows

Saturday, December 16th, 2006

For the Rails work I am doing in my spare time, I tried RadRails a couple of times in the past. Everytime I looked at it I found it to be promising, but it still didn’t convince me to get away from using the commandline and a simple text editor.

Well, last night I gave it another try, and this time it looked quite complete to me. I already had Eclipse 3.2.1 on my disk, and after a short installation of RadRails I was ready to go.

However, there was one thing I had to solve, and this is mainly the reason why I am posting this: Rake didn’t work. Whatever I tried, the error messages kept coming. Some tips, found at the RadRails site, said that I should use the rake script and not rake.bat. The only problem was – there is only rake.bat on my system.

The solution is quite simple, but I would like to document it here for future reference. I simply copied the ruby part of rake.bat into a new rake file in ruby’s bin folder. Then I pointed the eclipse configuration to the newly created rake script. En voila, rake is running fine in Eclipse!

Installing Typo 4.0

Sunday, July 30th, 2006

Just as a reminder: Installing Typo 4.0 doesn’t resolve its dependency to the sqlite3 header files correctly (at least not on my Ubuntu Breezy Badger). After

apt-get install libsqlite3-dev

everything went fine.

Upgrading ruby on Ubuntu Breezy

Friday, April 28th, 2006

Does that look familiar to you?

Rails does not work with Ruby version 1.8.3.
Please upgrade to version 1.8.4 or downgrade to 1.8.2.

Well, it happened to me again when I tried to put my latest project onto my server box. This time I decided to attack the problem. At Dirk Elmendorf’s “Economy Size Geek” blog I found a desctiption on how to use the ruby 1.8.4 backport: Breezy + Rails == No Go.

It turns out that, besides the 90 MiB download, it works like a charm.

Rewriting Wordpress in Rails

Friday, January 20th, 2006

Earlier when I wrote that I didn’t like the template language Wordpress uses, I also made the joke about rewriting WP in Rails. Well, today I thought “Let’s give it a try”. Not that I seriously want to rewrite WP, but I was curious to see how Rails can deal with legacy database schemas.

I was up and running pretty quickly: Pointed database.yml to my WP’s database, created Post and Author models as well as a post_controller. It was doing what I inteded it to do after a couple of minutes, but I didn’t like the column names (resulting in the attributes of the objects). It would have been too easy to write a new pair of accessor and mutator with nice names for each ugly column name. But, after all, Rails promotes the DRY principle, so I was looking for a better means to map column names to nice attrbute names.

So I found Joshua Sierles posting “Rails aliasing of database column names”, However, I wasn’t able to get it to run from the project’s lib directory, so I created a Rails plugin for it. I works well for me, and it’s good Rails style to put extensions into plugins.

If you like the functionality, you can download the plugin (alias_column.zip) and unzip it into the vendor/plugins directory of your Rails project. The plugin works exactly as Joshua describes.

I found one caveat, however. It doesn’t seem possible to use dynamic finders with the alias_column. I map the post_status column of the wp_post table to status, so I can call

p = Post.find :first
p.status

which works fine. But using p.status instead of p.post_status doesn’t work for the find methods. I want to call

Post.find_all_by_status ‘publish’

but it just throws an error saying

undefined method `find_all_by_status’ for Post:Class

Please leave a comment or mail me if you have an idea how to get this to work.

Rails on Ubuntu

Tuesday, January 17th, 2006

Joe wrote a nice, clean and straightforward tutorial of how to install Rails on Ubuntu Breezy.

By the way, if you enter “rails apache2″ into Google, it returns said article as the very first result. Interesting …

I started to follow the tutorial around 8 pm, and now, two hours later, I am done. Of course, in this timeframe I did not only install Rails. I created a new Ubuntu installation from scratch (actually a VMware-image), and put Rails with Apache 2 and FCGI on it. Works great!

Now I only need to find the time to rewrite Wordpress with Rails ;-)