I’ve mentioned Heroku a couple times before in my posts and I mention them again today. I was impressed way back then when I started 2 years ago, and I’m further impressed today.

I finally managed to get around to moving Morty from the now deprecated HerokuGarden onto the Heroku platform. And it was a cinch! (just one little surprise on the .gems file tripped me up easily sorted though)

The heroku gem makes life (too?) easy and even on a the most basic of basic (read: free) deployments, Morty is running pretty smoothly.


Morty py

Morty py is the same Morty that was built using Ruby on Rails as part of a bigger scheme related to the basics of financial learning, specifically the concept of amortisation. Morty py, as it’s creative name suggests, is a Python implementation. Moreover, it’s also hosted on Google’s AppEngine.

In all, the differences between the frameworks and development experience are both varied and the same. It doesn’t really matter which is “better”- that discussion is a moot point. But in summary, i love the RoR implementation for it’s expressiveness in code and coherence of the MVC pattern. But Google’s AppEngine rocks when it comes to functionality and the tool chain. Performance (for this app) is much of a muchness. Python is really nice, and so is Ruby. Granted, getting to grips with Python was much easier, but that’s only because my multi-lingual skills have improved greatly. And being a multi-linguist is so much more satisfying.

Afterall, imagine, in one day, coding the backend in Python, some related services in Ruby, maybe an optimized service in C, with a front end in C#, possibly ASP.NET or WinForms, a mobile front end in Java and then some obligatory JavaScript to boot. Not forgetting the frameworks that come with each of those languages that make them ultimately productive. For me, seventh heaven 😉



The most exciting discovery of the day award goes to Sweepers.
And the most straightforward “in the wild” dissection of it, goes to CodeLevy.

Basically, and in my cases unrelated to caching (not unlike David Parker), i needed to observe my controller actions. Well, i needed to couple behaviour onto an existing process and observing is (one of) the nicest ways to do it really.

When a user requests a report, let the controller do the checks and balances, pass it on to a presenter, and then let the world know a (correct) report has been requested. Interested parties (for now) include:
* monitoring for statistical purposes and
* rendering soft copies for prosperity (which in turn notifies the world that soft copies are available)

Sweepers are the new black for this morning.


Rails, PDF + prawn jumpstart

Looking for a “to-PDF” solution for your rails application? Well, if your journey is (has been) anything like mine [which is pretty standard judging from what i’ve read] then you’ve probably decided prawn is the way forward. And you’re also probably convinced that prawnto is a good idea (it is also highly recommended).

So by now you’ve created a blank rails app, installed the gem, added the plugin, got a controller of sorts setup- all for the purposes of test-driving prawn (with prawnto). You’ve reread the documentation but it’s not going _that_ smoothly. There are one or two little things (not mentioned as explicitly as you’d might want) that you should be aware of. After trawling through some prawn discussions on google groups, i picked a bright penny-moment. Aha! Of course 🙂

Sometimes, while learning a new library/tool/tech/whatever, your brain seems to focus too hard on the problems you’re experiencing and forgets about the basics of the bigger context. When you step away, you (hopefully) realise that the issue you’re having is not the library/tool/tech/whatever, but with the fact that some fundamental got glossed over/ignored/forgotten about. This was one of those.

My controller code was fine. The actions were pretty much {empty}. My view filename was either action.pdf.prawn, action.pdf, action.prawn.pdf, action.prawn or actionpdf.prawn- all sorts of variations ‘cos i couldn’t consistently get the desired effect: an inline pdf render. But the documentation said quite clearly ‘.pdf.prawn’. What does it take to get a simple demo going to start experimenting with? Well… it turns out all i had wrong was the request. I completely ignored the basics (routing) and focused on the problem (pdf library). Not exactly a library issue.

http://localhost:3000/controller/action won’t work => renders .html
http://localhost:3000/controller/action.pdf won’t work either => no route

What i wanted to request was: http://localhost:3000/controller/action/:id.pdf
and :id is the identifier for your model (even if you’re not actually riding with one in our test drive).
And this is due to the default configuration of a default rails app. Check out your routes.rb. Back to basics. Evidently, if you want a different ‘route’ to get to your pdf, then, you guessed it: create a route 🙂


Deploying Rails

A while ago, i got addicted to RoR. Life before RoR was… well. Mundane. Don’t get me wrong. There was still a lot of exciting stuff going on, but RoR opened up a brave new world and it’s “differentness” added to its appeal. And since then, i’ve written a fair amount of Rails apps and a few libraries in Ruby for my own use. And then i tried to deploy a Rails app.

… ?:o

It was hard. And especially hard since i couldn’t eat, sleep and breathe the environment; so every opportunity i got to tackle the problem, i had to relearn the same commands. But i got used to it. I read _a lot_. And i managed to actually understand the conversations at one point. A major plus 🙂

In case you’re wondering what a *normal (or typical?) deployment might look like, take a peek here.

*Normal or typical probably doesn’t even exist, it’s just a phrase which suits my goals at the moment.

In any event, there’s some configuring going on. Examples are here, and here, and here. And there are more.

And despite the seeming “mission” related to deploying apps (and why a lot of folk just abandoned the platform altogether), i still believed it would get better. It just had to.

Hello, Phusion Passenger. Phenomenal! And suddenly, the roses are redder, the skies are bluer, the birds sing clearer and the apps deploy smoother. Waaaay smoother. Keep your eye on this one!

Oh. and here’s more about using Phusion Passenger in development.


Will it Scale?

When Ruby/Rails is mentioned as a web development platform, the most common response is related to scalability and performance; usually with a liberal dash of skepticism. Fear, uncertainty and doubt, along with a couple of honest posts and reviews, all point to the perception that Rails has some sort of performance problem.

300 million page views per month anyone?

Good to hear about the success stories, no matter the tech, but particularly heartening to see the RoR tech maturing into something more than just a “toy”.


Ruby Nuby Catch

I was reading up quite a bit and getting a project on the go with Ruby and Streamlined. Perfect for an admin console and mass data capture application. But in my zeal and learning curve, i kept bumping my head against habtm relationships not really working. It was acting weird, and depending on when you pick up on the glitch, you’d explain it a dozen different ways.

Short story long, i scoured- found folk with similar issues and put it down to “bug”- but not convincingly.

And then i was reminded: habtm tables don’t need a surrogate primary key for ActiveRecord development! Doh! changed my associative table scripts to include :id => false and it all works like a charm!

Now if i can only find those threads again and post the “solution” there… Arrrrgg..

But here’s a fantastic post/tutorial on the issue by Sam Aaron.


Bitnami Application Stacks

If you’re looking for an application stack to run on *any* OS, particularly one of the very famous and useful open source applications (subversion, wordpress, joomla, drupal, apache, ruby, moodle, mysql, php, trac, …) and want to get started quickly, i would suggest bitnami for most your needs.

And especially if you’re stuck with a Windows server :p but really need to set something useful (server application) up and running, chances are, bitnami will have a stack you can download, click and install. They even have got Ruby on Rails. And the growth in the last few weeks has been quite considerable (ito offerings) so there’s very little excuse for not trying out (self-hosting) any of these wicked-cool apps on your internal networks 😉