Ruby (on Rails)

Last week, I started looking into using WATIR for web application testing. In the short amount of time I spent with the tool, I got an initial look at Ruby. Aside from seeing it here or there, this was the first time I actually wrote any Ruby code — but it was mostly cut and paste based on the testing examples.

Today, I realized that Ruby (and Ruby on Rails) is part of Leopard and delivered with OSX. So I fired up a terminal window and started playing around with the console (IRB). Mind you, I was only playing around with it at this point so I didn’t get too deep. I created a few classes, learned the value of open classes, added some methods to the built-in classes (like String.is_your_mom), etc. I was basically playing around without any instructions.

Tonight, I started reading a few articles on the Apple web site about getting started with Ruby on Rails using Mac OSX. I created an application, created some models and a migration, installed and configured MySQL for use in development and test, and created some scaffolding to be able to perform basic CRUD against my domain model. It was at this point that I got an idea of how web applications could be created using Ruby on Rails.

The part that concerns me with what I’ve learned so far is that ActiveRecord is handling all of the mapping of database columns do the domain model. I’m not sure this is how I would really want that to be done, but I’m so new to Ruby I can’t be sure. I’m going to find some examples of applying DDD to Ruby on Rails and see if the two play nicely together. It seems like a lot of the Ruby framework expects a lot of things to be named specific ways or it all breaks down quickly. I do know that I’m not a big fan of having the model defined from the database.

I also know that building an application with a Rails web interface might also lead to building supporting application services in other languages using the same database. In that case, it would seem that having a model-driven architecture that can generate the classes for both Ruby and C# (and likely Java) would be very useful. I have Sparx EA, but I’m not sure if it supports Ruby yet or even if that is how I would want to go.

I’m going to pick up a couple of Ruby books to read more about it — it seems Idiomatic Ruby is a good place to start. Who knows where that will lead!

Related Articles:

    Post Footer automatically generated by Add Post Footer Plugin for wordpress.

    About Chris Patterson

    Chris is a senior architect for RelayHealth, the connectivity business of the nation's leading healthcare services company. There he is responsible for the architecture and development of applications and services that accelerate care delivery by connecting patients, providers, pharmacies, and financial institutions. Previously, he led the development of a new content delivery platform for TV Guide, enabling the launch of a new entertainment network seen on thousands of cable television systems. In his spare time, Chris is an active open-source developer and a primary contributor to MassTransit, a distributed application framework for .NET. In 2009, he was awarded the Most Valuable Professional award by Microsoft for his technical community contributions.
    This entry was posted in rubyonrails. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
    • http://www.flux88.com Ben Scheirman

      The “Skateboard” book is great… Agile Web Development with Rails.

      Also, you should check out Why’s Poignant (?) Guide to Ruby. It’s hilarious even if you don’t want to learn ruby. Plus that guy (Why) wrote a pretty good html parsing library called Hpricot, so if you ever have to do any screen scraping of web pages, check that out.

      Keep in mind that a lot of changes have been made since most of these articles and books were written, so you may notice some quirks here and there.

    • http://blog.sideline.ca Mike McClenaghan

      For your first shot with Rails, try to just “go with the flow”. There’s a lot of processes from the “Alt.Net” world that just aren’t needed as much in Rails. Said another way, don’t get caught up in premature optimization. :)

    • http://www.lostechies.com/blogs/chris_patterson Chris Patterson

      Okay, so I’m going with the flow. I read through the skateboard book last night and worked through the store example. I find that it’s a pretty good read actually. And there are certainly a lot of supposed things that are handled by the Rails framework. It seems to just work, and clarity is a good bonus. Since it’s using convention over configuration, everyone trained to build Rails applications adheres to that convention (well, I’m sure there are strays).

      The ability with which many of the “2.0″ features are applied, AJAX, etc. make me so envious of people who started using Rails long ago. These things are so easy in Rails, using Partials and such to easy the updating of areas on the page. Could the Microsoft MVC framework be learning more from Rails than I thought originally?

      I’m still trying to figure out how to qualify statements about Ruby in general that I’ve heard at various ALT.NET meetings:

      * Dependency Injection isn’t an issue in Ruby

      Okay, that’s only one. But I’m also still trying to see how you would do such a thing and allow different classes to handle an implementation at runtime. Is it all base classes or are there interfaces as well?