Find objects in IRB directly from browser URLs

Posted by Dr Nic on January 01, 2008

A long time ago, I tired of going into the irb/console and finding objects/models using the traditional ActiveRecord command Person.find(15) and now I’m sitting pretty: I can paste in URLs to fetch objects.

# No more of this:
=> Person.find(15)
# instead:
=> people/15

people/15 is something you’ll copy+paste directly from your browser: http://localhost:3000/people/15

Of course, the url is based on your routing + controllers, so the assumption here is that your routes/controllers map to your active record models. That is, your app is smothered in RESTful love and cuddles.

Not following this? Here’s a video:

How to make this work at home

Copy and paste the following into your .irbrc file:

Thanks goes to…

The some original code for this comes via Mike Clark, who had the idea for syntax activity(6). This was good.

I previously had another idea to support the syntax 6.to_activity using the RubyGem to_activerecord. I still like the id.to_class_name structure of this and still use it.

But if I have a perfectly nice looking url sitting in front of me, I can now paste the class_name/id part into irb and I’m off and running.

Happy New Year.

Everything you wanted to know about Ruby.NET

Posted by Dr Nic on October 29, 2007

Recently Wayne Kelly spoke at the Brisbane Ruby and Rails Brigade about Ruby.NET (code repository).

We figured he was some authority figure on the topic, as he wrote it, together with some other members of his QUT department, plus a growing number of Ruby.NET users and contributors.

Local Microsoft officialdom sponsored the show with pizza and then drinks afterwards. Ok, I’m understating that - Charles Sterling is an ex-.NET project manager, who is now in Oz for a Tour of Duty as an Evangelist. In his capacity as an evangelist, he giveth us thy pizza. Twas tasty too.

I believe Ruby.NET is in direct competition with IronRuby for the hearts and minds of Ruby/.NET/Windows developers.

Wayne starts the video below with a comparison of the two, plus a few other Ruby implementations (sorry Evan, Rubinius wasn’t mentioned).

Fortunately we were treated to a demo early in the show. Wayne had recently implemented Ruby code-behind for some of the drag-and-drop widgets that come with Visual Studio. It was very sexy to see all that Ruby being generated.

The video also includes lots of “why Ruby is hard to work with as a compiler writer”, and more importantly, there are lots of audience questions all throughout the talk. This might be why the talk is 1.45hrs long!! :)

Enjoy… (and the slides from Wayne)

Dr Nic at RubyConf 2007 - RubiGen - Teaser

Posted by Dr Nic on October 25, 2007

4th of November 2007 - 9am - main conference room - RubyConf 2007…. comes … RubiGen.

Turn up the volume and enjoy that 80s theme music…

Can’t see the video?

RubiGen video from RejectConf Berlin

Posted by Dr Nic on September 22, 2007

Go straight to video below

I took a video recorder to the RejectConf, like I did in Portland. Unfortunately, there were two reasons I didn’t record any of them.

Firstly, there didn’t seem to be any obvious place to position the camera.

Secondly, it was deemed critical that everyone does their talks in the dark. The conference isn’t run in the dark, local Ruby groups don’t run meetings in the dark but consecutive RejectConfs have been run by adminstrators with a dark fetish. Great for drinking beer and heckling presenters. Bad for video recording.

The makers of the JVC HDD camcorder - a nifty device with a 20G HDD in it - don’t make it possible to record in the dark. Not because it doesn’t have a “night time mode” - apparently it does - but when you are already in the dark, you can’t figure out how to turn it on.

Ok, fine, if I’d made an effort I could have figured it out. So, let’s use excuse #1 as the reason for not recording the presentations.

Its a valid excuse, the Pirate Cove was chock-a-block full of people. The local Berlin Ruby Group did an awesome job of finding a great “underground”-esque venue.

Fortunately a fellow Australian - Marcus Crafter - had a front row position, and a MacBook Pro. With said device, he captured my talk on RubiGen (and John Barton’s).

RejectConf video of RubiGen

In 5 minutes, I make a Merb generator, using RubiGen and NewGem. Nifty stuff indeed.

Recorded and published by Marcus Crafter

There were lots of other awesome presentations (that is perhaps a dubious inference that mine was awesome), but it was dark, I had beer in both hands, and I was too busy yelling “AUSTRALIA!!!” to write notes.

What a great night :)

Missed Ze Frank at Railsconf? [video]

Posted by Dr Nic on June 02, 2007

Neat. Here is Ze Frank at TED 20062004 [thx Erik Kastner]. A lot of the material is similar to the 2nd half of his Railsconf presentation; so if you missed it or miss it, check it out…