Archive for the 'Ruby on Rails' Category

SWX Ruby updates to Alpha 0.1.1, has new screencast

Swx Ruby Silent Movie

Jed Hurt has updated SWX Ruby, the SWX RPC implementation in Ruby (currently for Ruby on Rails) to Alpha 0.1.1. He has also recorded a new screencast to show you how to get up and running with it.

Check out the SWX Ruby homepage and the SWX Ruby blog.

Boston, a new camera, iPhone, and SWX Ruby

What a day! It feels like Stephanie and I walked most of central Boston (and it was a lovely sunny day for it too!) I also splurged on a new camera (a Canon 400D) so I can better document FlashForward and the other conferences I'm speaking at, and an iPhone (because I really, really wanted one and we don't have them in the UK yet!)

On the matter of the iPhone: Of course, now that I have one, I know that Tuesday's press conference will announce their availability in the UK! Oh well. I'm on my way to unlocking mine (activated it via Independence/Jail Break) and I should have it working on my T-Mobile sim tomorrow via the simfree software hack!

Oh yeah, and the big news: SWX Ruby! There's a Ruby implementation of SWX RPC now thanks to Jed Hurt. It's currently in Alpha and works with Ruby on Rails. I tested it on my Locomotive install today and it worked like a charm. Go Jed!

FlashForward registrations are tomorrow. Come by and say hi if you're coming over!

SWX Ruby Alpha: SWX RPC for Ruby on Rails

Swx Ruby Alpha

This is so cool: Jed Hurt has released Alpha 0.1 of SWX Ruby, the Ruby implementation of SWX RPC for Ruby on Rails.

Jed and I have been corresponding on email about SWX Ruby for a little while now and it's amazing to see how quickly it has materialized. Jed, you rock!

Getting started with SWX Ruby

Here is the Hello World example from SWXRuby.org.

The service class:

class HelloWorld
	def just_say_the_words
		'Hello World!'
	end
end
 

The ActionScript (using the native method of SWX RPC):

//There is a movie clip on stage with instance name 'loader'
loader.serviceClass = "HelloWorld";
loader.method = "justSayTheWords";
loader.debug = true;
loader.loadMovie("http://localhost:3000/swx", "GET");
 
function onEnterFrame()
{
	trace(loader.result);
}

In other words, it's just like SWX PHP but you write your service classes in Ruby. That rawks! (Yeah, with an "a" even!) :)

To install SWX Ruby Alpha 0.1, you simply type the following command from your Rails project folder:

script/plugin install http://swxruby.rubyforge.org/svn/tags/0.1/swx_on_rails

If you want a quick way to get up and running with Ruby on Rails on OS X, check out the excellent self-contained one-click installer Locomotive.

(Also see my related posts on Locomotive and Ruby that may come in handy: Creating applications with RoR on OS X, Using Locomotive as your default Ruby, The location of the Rails source under Locomotive, and Clearing the gem source_cache in Ruby.)

A note on ports in general

I have been busy with getting SWX PHP to version 1.0 and haven't had a chance to concentrate on orchestrating the ports but this is something that will change now that version 1.0 is out. I'm trying desperately to get the Internet Drafts for SWX and SWX RPC together and write a guidance document for ports/implementations of SWX RPC.

The key points to note about ports/implementations is that they should be compatible with:

  • SWX ActionScript Library
  • SWX Tools (SWX Service Explorer and SWX Data Analyzer)
  • The dominant/popular open source Flash Remoting implementation for the platform (e.g., OpenAMF, WebOrb for RoR, etc.)
  • Adhere to SWX's core philosophy of system-wide simplicity and mirror the simplicity of the one-click install of SWX PHP and the SWX PHP Start Page.

The idea is that SWX RPC implementations work the same way regardless of the platform that they are implemented on.

Thank you, Jed!

Jed, you can't believe how much I appreciate your work on SWX Ruby and I can't wait to see SWX Ruby evolve in the coming days and weeks.

Clearing the gem source_cache in Ruby

I was trying to install a Ruby Gem when I got the following error message:

ERROR:  While executing gem ... (Gem::GemNotFoundException)
    Could not find xhtmldiff (> 0) in the repository

Googling around, I found out that this error may mean that the source cache is corrupt. Sure enough, that was the problem.

To fix it, under Locomotive, I deleted the following file:

/Applications/Locomotive2/Bundles/rails112.locobundle/i386/lib/ruby/gems/1.8/source_cache

And that fixed it! :)

Rails could be DRYer

I'm playing with Ruby on Rails these days and I've been thinking about how Rails isn't entirely DRY. (i.e., doesn't implement the Don't Repeat Yourself philosophy fully.) The area where it falls short of DRY is in the duplication between defining the database schema (either manually, or through the use of migrations) and defining the Model.

In Rails you can define constraints and validations in the Model. You repeat the Model definition when you create migrations to create your database structure (or if you create you create your schema manually, when you do that.) You repeat the constraints (e.g., foreign keys) in the database also. For Rails to be completely DRY, it should generate the schema and update the database automatically based on the current state of your Model classes. (Allowing overrides that go low-level, where necessary, of course for specific optimizations or advanced SQL.)

Googling around, I came across this discussion of a suggestion for ActiveSchema where people are discussing the same thing.

The location of the Rails source under Locomotive

I was looking for the source for the various generators in Ruby on Rails in my Locomotive install and it took me a while to find them. For the record, I found it in:

Locomotive2 → Bundles → rails112.locobundle → i386 → lib → ruby → gems → 1.8 → gems → rails-1.1.2 → lib → rails_generator → generators

Creating applications with RoR on OS X

You've no doubt heard about Ruby on Rails (RoR) by now. It's a full-stack Model-View-Controller (MVC) framework for creating web applications using the Ruby programming language. RoR adheres to the Don't Repeat Yourself (DRY) principle and uses the dynamic nature of Ruby and the idea of convention over configuration to reduce duplication and code line-count without sacrificing maintainability or scalability. In short, it's a Good Thing! Even better news: If you're on OS X, it couldn't be easier to get up and running with RoR thanks to a one-click installer and administration application called Locomotive. Here is a quick tutorial to get you started.

  • Download Locomotive and install it by opening the image file and dragging the application to your Applications folder.
  • Run Locomotive and click the + button in the control bar. Select "Create New" from the button's menu.
  • Give your application a name and select the directory (folder) that Locomotive should create it in.
  • Press the Create button

That's it, you've created your first rails application!

To run the server for your application, select the application's name in the applications list in Locomotive and press the Run button. Now go to http://localhost:Port (where port is the port that is listed next to the application's name in Locomotive) and you will see the default Rails welcome screen.

One caveat: If you're using MYSQL via MAMP, you need to add the following line "socket: /Applications/MAMP/tmp/mysql/mysql.sock" to your database configuration file (config/database.yml) when working with RoR. That one caught me out until I found the note in Locomotive's help files.

To learn more about rails, check out the tutorials on the Ruby on Rails web site.

So how does this all apply to Flex/Flash development? Well, MidnightCoders has a Flash Remoting solution for Ruby on Rails called WebORB for Ruby on Rails that supports both AMF0 and AMF3...






Bad Behavior has blocked 0 access attempts in the last 7 days.