Archive of November 2006
Ruby on Rails dipped in Cocoa
I recently came up with an idea that just might be a good one. Why can't I embed a Ruby on Rails application inside a Cocoa application and have said Rails application actually do Cocoa type things. It turns out I can. After a few hours of playing I managed to get something working.
This is my first encounter with rails apart from skimming a rails book I have so a lot of the time was actually spent on rails itself and not the Rails/Cocoa interaction. All in all, you would have to say that it kind of fits together pretty easily at this point.
Why would anyone want to do this? Cheap client/server type applications. And whats more, cross platform clients. You have a web application, that on the server side can theoretically do anything that a Cocoa application can do. For me at least several possibilities spring to mind, but that is another post.
There are three ingredients here: Cocoa, Ruby on Rails and RubyCocoa.
RubyCocoa is a bridge that lets you call into Cocoa from Ruby and vice versa. So the general idea is that the rails code can actually call into the runtime of the application that it is running inside of. Pretty nifty.
I have put together a proof of concept. It don't do much and it ain't pretty. The application has a window with a button that when pressed will start up rails (via WEBrick), over the RubyCocoa bridge. The rails app has one page with a text field and a submit button. Enter text in the field, hit submit and the host application will speak the words. Not ground breaking, but it illustrates the point. So, if your machine is internet accessible on the port that the rails app is running on, you could have any of your interwebs brethren make your computer talk.
At the moment it is all very ugly, the emphasis is just on getting something happening to show it can be done. This is my first foray into rails so there are some relics in the code that probably don't need to be there. But all in all there is very little code. It should be easy to dissect what is happening if you look at the code.
So without further ado, here it is as an Xcode project. Now you will need to have RubyCocoa installed. Also, I don't have a second machine to test it on so there may be some me specific Xcode project settings that will stop it from building.
Once you have it built and running, click the 'Start Rails via WEBrick' button (you can't miss it, its the only one) to get rails running. Then go to http://localhost:3000/say, type something in the text field and hit 'SPEAK!'.
This is only a start. Expect to hear more.
10:45 PM | 3 CommentsDomain Name Woes
I am trying to get my web site moved from my current provider to a shinier newerer betterer one. This is proving to be a total pain in the ass.
Lesson: Never buy your domain through dodgy offshore domain name resellers
I have been reluctant to post here because I had already migrated all of my content to my new provider. I'll post more on the saga post move. I don't want to start defaming the very people I am trying to get to help me.
02:33 PM | 0 Comments