Petri Wessman's weblog

Coding on Rails

This week I’ve been coding quite a bit on my free time, for a change. I’ve been following Ruby on Rails since it was at version 1.0 and have done some small toy test apps, but to date I haven’t really built anything biggger with it. I’ve had plans, sure, but somehow just never got started – part of that is just an overabundance of stuff I’d like to code, I could never decide what to do. I’d like a wiki that works just like I want, I’d want a nice simple photo gallery, I’d like lots of tools to help with rpg gamemastering, I’d like a pony… well, scratch the pony, but you get the drift.

Rails is (really!) great, and it allows you to develop more or less as fast as with PHP without needing to touch the Mindshatteringly Horrid Piece of Shit(tm) that is PHP. You can write web apps in an “agile” fashion while keeping the architecture clean, with a level of abstraction that I like. It’s somewhere between the over-engineered N-levels-of-cumbersome-abstraction maze of J2EE and the “easy web apps for people who don’t know how to code” of PHP. Me likes.

…but naturally there’s some setup involved when you want a system with user management and authentication, deployment with Mongrel & Capistrano, and all that stuff. The restful authentication plugin makes building a user auth system a bit less painful, but it’s still quite a bit of work (I’ve been following hints from various sources). So there’s quite a bit of startup intertia involved whenever you want to write a non-toy app. It’s a whole lot less intertia than with most other system, but it’s there, still.

Anyway, I realized that I don’t need to write N separate web apps, each duplicating a large part of this functionality – I can just write one app, with lots of subsystems, expanding them as needed and using one user auth system for all. Since this will be mostly for my own use and I don’t need to worry about it being modular and useful for others, keeping the apps separate would just involve (a lot) more work for me and bring no real benefit.

So I’ve been coding during evenings, using a snapshot of the new Rails 2.1 and using all the new conventions and toys (REST, named paths, named scopes, etc). It’s been fun, it’s been a while since I had a coding project, and I’ve been learning a lot of practical Rails stuff at the same time.

To date, I have a working (if simplistic) wiki, a user authentication system with email confirmation, and the beginnings of an Exalted character builder/manager tool for my Exalted game. Deployment is handled by Capistrano, and the thing runs on a (currenly single) Mongrel instance with Apache proxying. The intention is to expand it with a blog engine at some point, and maybe move this blog over – but that’s (far) in the future. That would also need some sort of image upload capability, which overlaps with the photo gallery I’d also like to have one of these days. Work work.

In any case, it’s a fun project.

Otherwise it’s been pretty quiet. Went to basic swords training on Tuesday, was fun – but somehow managed to do something bad to my heel. Didn’t notice anything that evening, but the next day it was very sore and I had to limp along. Janka thinks I may have inadvertently over-stretched my Achilles tendon (or some such) before it was warmed up properly, but that’s just a theory. In any case, it seems to be getting better now and it hardly hurts at all even if I stretch the sore spot… so should be able to go to training next week without problem. It might have been ok to go yesterday, but I tend to be very careful when it comes to foot/joint/tendon problems. I’d much rather miss out one week than to really aggravate some spot, that an easy recipe for getting problems that will need weeks or months to heal. Sore muscles, no problem. Seriously hurting tendons or joints? Danger sign. For me, at least.

I’m still a bit mystified by what caused the thing, but sometimes these things happen. My body is telling me that something is (or was) wrong, so that’s that.

Looks to be a busy weekend, a party on Saturday and an Exalted game to run on Sunday. Need to squeeze in some game prep today and Saturday, even though I’m mostly ready… some details still need fleshing out.

Published on by Orava, tags , , , , , ,


Ok, I’ve been playing around with Typo a bit now and it seems a lot nicer than Wordpress. A lot of the “nicer” comes from it being written with Ruby On Rails, which is a kick-ass platform, especially when compared to the steaming pile of dung that is PHP. Don’t get me wrong, WordPress is very nice – but Typo suits me more.

It helps that I’ve done some stuff with Rails, and I know how the framework is organized and is intended to work. This, together with Ruby being a nice and concise language, makes peeking under the hood in Typo a pleasant experience, as opposed to the “aaaagh, I want to claw my eyes out!” reaction I get from PHP and WordPress. I’m already thinking of writing a sidebar plugin or two, they seem pretty straightforward. I also want to add a text filter to generate DriveThruRPG links easily.

The installation and setup was pretty straighforward, the new installer defaults to a Mongrel server which suits me fine. I ended up with Mongrel listening to a port on the local interface, with Apache proxying requests that way. Rails is not thread-safe, so Mongrel wraps most of the app in a sync block – which is fine for a small site like this, but would not scale for more traffic. Luckily, Mongrel has support for running a cluster of Mongrel instances, and Apache 2.2 and later have a load balancing proxy module that is reported to work. I don’t need that now, but it’s good to know that stuff like that exists. All in all, it seems that the Mongrel + proxy solution is a very painless way to deploy and administed Rails apps. Nice. Production deployments have always been the slightly ugly side of Rails, up to now at least.

Published on by Orava, tags , , , , , , ,

Powered by Publify – Thème Frédéric de Villamil | Photo Glenn