Ruby Manor

Media_httpwwwrowthebo_qkfij
Yesterday I spoke at and attended Ruby Manor. It was a grass route conference with the attendees determining the agenda and the organising duo aiming to keep costs to an absolute minimum. So successful were they infact, and as one twitterer aptly points out, that for an amazing £12 you got a series of excellent talks, no annoying sponsorship and £500 behind the bar at the end of the night. Given even the cheapest of conferences aimed at freelancers clocks in well over the £100 mark, this really was a fantastic achievement.

On a personal note I presented on nanite which is a background processing solution for rails and merb. It was quite a technical talk and I was trying to get a lot into the 30 minutes timeslot, so it felt a little rushed. Nevertheless most people seemed to grab the concept and the live demo at the end went really well. For those that missed the event I'm sure the videos will be online soon, but in the meantime there's an excellent coverage on this blog and the slides from my presentation are available on slideshare or below:

ActiveRecord outside of Rails (and YAML)

Lately I've been working on a stock trading program that automatically trades and saves the results to a database (more details to follow in the not too distant future...)  Naturally the choice of language was ruby, and for the front end, a rails application.  Once coded, I bundled the stock trading program into the rails lib folder and reused the rails model for saving to the database.

I ran into a slight problem doing this though as ActiveRecord needs configuring manually outside the rails framework but I wanted to follow best practices and keep my code DRY. After a quick search I found a clean solution that allows you to re-use the database.yml configuration file from the rails application:

dbconfig = YAML::load(File.open('config/database.yml'))
ActiveRecord::Base.establish_connection(dbconfig["development"])

This snippet got me thinking about YAML which I use a lot but have never played with in Ruby. It turns out the YAML class is basically a hash that uses strings (gotcha not keys) to access a simple hierarchy:

dbconfig = YAML::load(File.open('config/database.yml')) 
dbconfig["development"]["adapter"] # = mysql [/sourcecode]

All very simple stuff but if its never crossed your mind before, you yet again appreciate the elegance of ruby.

MERB: The new rails?

I presented on MERB last weekend at Barcamp London 4 I've been using the technology the last two months at Bablo so it was good to share my experience with other users. With it being quite a bleeding edge technology there was just a small gang of us there but there was plenty of good discussion. The talk I gave had a purposely provocative title but ended with a great quote by Ezra

more choices make the Ruby ecosystem a better place. So let’s just stop with the Rails VS Merb stuff. How about people choose what framework they want to use based on the frameworks merits and features rather then religious arguments about how my framework can beat up your framework.

I was then flicking through some slides from the recent RubyConf and was mightily impressed by a slide from the end of the MERB talk:

It's consider a bug if:
* It's not documented
* MERB gets slower
* There's a public API change without prior deprecation in a timely manner

It seems the guys at EngineYard have a great attitude, not to mention a really well thought out framework. I'm looking forward to using it fulltime.