Refactoring code logically

February 12, 2008 12:28pm | 2 Comments | , , , , , and

And now an example of how I write my ruby code and get it down to the bare, readable, minimum code needed. This is real life code taken from a website I'm building, but I've changed the objects to a blog post because more people will relate to that easier.

The show object has an id passed in using the params Hash, I want to check if that post exists in the database first. If it does, then render the page, and if it doesn't return a 404 error page.

So I start off by writing this in longhand ruby, I'm using the merb framework with DataMapper ORM by the way....

More...

Use datamapper sessions with merb & datamapper

February 5, 2008 8:27pm | 1 Comment | , , , , , , , and

Issue

Can't use merb sessions with datamapper & mysql, get back an error about needing an id on the text column or something (I had the error a couple of days ago.)

Solution

I suggest grabbing merb_datamapper svn source to fix this in. To do so make sure you have subversion installed on your machine (I'm assuming a Unix based machine here.)

  1. Checkout the source ...

More...