Creative technologist and interactive artisan

Presenting Rails for Flash at LFPUG

Posted: October 27th, 2008 | Author: Daniel | Filed under: Actionscript, Architecture, Flash, Open Source, Project Management, Ruby on Rails, User Groups, Web Applications | Tags: , , , | 1 Comment »

Ruby on Rails Logo

As usual, the London Flash Platform User Group event will be held on the last Thursday of the month; that’s this Thursday, October the 30th.

First up this month are the guys at Unit9, they’ll be taking you through their processes and how they keep everyone in the company communicating effectively for maximum result.

I will be following up with a presentation on Ruby on Rails and Flash; taking you through the steps needed to create a REST-ful Rails application that is read and writeable through a Flash Front end. This will give you an introduction to Ruby on Rails and how this powerful web application framework can make it ridiculously easy for you to kick-start your next, or first, database powered Flash application.

The LFPUG will be held at it’s usual location, Cosmobar on Clerkenwell Road (54-56) and the presentations start at 19:00. For more information on the sessions, and indeed on how to get there, see the official LFPUG site.

See you there!


Insoshi: kickstart your social app

Posted: June 2nd, 2008 | Author: Daniel | Filed under: Architecture, Cool sites, Open Source, Ruby on Rails, Web Applications | Tags: , , | No Comments »

Insoshi logo

Insoshi is an open source social site with everything you would expect; messaging, blogging, connections and much more. If you download the source (writen in Rails), you’ll already have a fully operational social software platform to kick start your idea. To top it off, things can only get better; Insoshi is under active development.

If you’ve used Ruby on Rails before, you should feel very comfortable browsing the source, it is written in a concise and professional manner. For the novice Rails developer, Insoshi provides a great opportunity to understand the architecture of a fully functional Rails site. You’ll learn a lot from browsing the source of a complete application, something I found difficult to find when first embarking on my own Rails adventures.

Head on over to the Insoshi site to get started on your own adventure.


Migrating to RESTful Rails

Posted: April 2nd, 2007 | Author: Daniel | Filed under: Architecture, Ruby on Rails, Web Applications | 1 Comment »

This weekend I decided to re-architect a Ruby on Rails application I have been working on and migrate from an RPC architecture to a RESTful architecture. Wikipedia has a good article on REST that also compares RPC to REST so you may want to check that out before going on, although I’ll briefly explain REST in the next paragraph.

REST stands for REpresenataional State Transfer and differs from Remote Procedure Calls (RPC) because you don’t have to create a specific method for each type of CRUD manipulation. Your methods react differently depending on the way in which you actually request them. Rails looks at the http request type to decide what to do to the resource. The 4 available request types are POST, GET, PUT and DELETE. Most browsers don’t support PUT or DELETE requests so Rails fakes them; in other words you don’t have to worry about them right now.

Rather than pollute the internet with another attempt at explaining REST, I think I’ll just quit while I’m ahead and let the guys at B-Simple take over from here. Ralf Wirdemann and Thomas Baustert have written an excellent PDF guide to RESTful Rails which you can download from their website. I highly suggest checking it out; it’s a great resource that has only recently been translated to English.

Now Rails being Rails, it offers a great way to jump-start your RESTful web application: the scaffold_resource generator (available since Rails 1.2.)
Creating a scaffold resource of a database table creates a Rails controller with a number of different CRUD methods for that resource, it’s bloody fantastic! It’s a lot like the old scaffold generator, it gets something up quickly after which you can edit away to your hearts content.
Another really cool thing about Rest and Rails is that Rails allows you to specify a format in which you would like to receive the information; you want xml? Just tag add a .xml to your url and away you go. RSS? No problem, you already know what to do.

After migrating to the new structure I had a couple of problems; when I accessed my resource and provided a format it worked, but if I omitted the format it would generate an exception. (e.g. accessing www.mysite.com/products/1 gave me a “no action responded to 1″ error, while accessing www.mysite.com/products/1.xml worked just fine. Check out that PDF for more info on how formats work.

After a couple of hours I found out what my problem was. Because I was migrating the application, I had manually added my resource mapping to the routes.rb config; eagerly adding the resource to map at the bottom of the file (e.g. map.resources :products to map a table named products.) That was a mistake as lines at the top of the file take precedence over those at the bottom. As soon as I moved the resource mapping to the top of the file everything was working as expected.

All in all, migrating my application to a RESTful architecture was quite quick and easy and my existing authentication and authorization systems were easily dropped in afterwards. I now have a very flexible architecture that will allow me to make remote server calls from Flash, html, rhtml or pretty much anything else and specify a custom format in which to receive my data.

Life is peachy once more.