Playing with Ruby on Rails

I've had this on-again, off-again experience with Ruby on Rails. For those of you that don't know Ruby on Rails is a really simple framework and model for building Web applications very quickly and easily. This is not new news and in fact Ruby on Rails has gotten some very significant attention. As a Microsoft guy for many years I simply glanced in the direction of Rails and said "meh". I was immersed in the Microsoft development tools for so many years I wasn't willing to look very hard at things outside my .Net / Visual Studio / C# comfort zone.

My positive experience with my Mac switch led me to rethink that strategy, or at least give it a much better try than the quick glances I gave it before. I did a lot of research, found a lot of information and have found lots of controversy as to whether there is a future in Ruby on Rails. I've also found lots of evidence that some pretty large sites are using Ruby on Rails for their projects. In spite of all that I am in the early stages of really pushing it and so far I like what I see.

The initial challenge was setting up the right build environment which included a MySQL instance and several other components. I struggled with it at first because it was so difficult to deal with, hence the off-again part of the experience.  Part of the challenge was that Ruby on Rails (RoR) was in a transition from 1.2 to 2.0 and there were some significant changes to the framework. I started playing with Rails before most of the help and assistance information was updated to reflect the new 2.0 version.

A few weeks ago I came across a post on the Apple Developers site that walks through what's required to actually get Ruby on Rails 2.0 set up and running on Leopard. Turns out I was using 1.2 instructions for getting Rails up and running and the release of 2.0 switched to use SQLite3 as the default development database engine. If you have ever entertained the idea of playing with Rails and you are running Leopard, check out that two part post. It's really easy to follow along with.

One of the things that Apple did and documents in that post is allow you to use Xcode to manage your Rails project. While I found the environment to be pretty cool I liked the editing surface in TextMate, which also has pretty good support for Rails constructs and Ruby code.

In addition I went out and purchased a slew of books that I figured would help me in my education with Ruby the language and Rails the framework. I'll list some of these in later posts as I form more of an opinion on them. One word of caution though: If you just run to Amazon like I did and buy Agile Web Development with Rails you will be disappointed. Not because it's a bad book - I like the style - it's because the book's tutorial does not work with Rails 2.0. They are selling a PDF version of the new book that is supposed to come out in October that will have a tutorial that actually works. 

In the mean time if you want to give Ruby on Rails a quick spin on your Mac you should follow those Apple Developer instructions I linked to. Here are a couple more that may get you started and help get some perspective on Ruby on Rails:


Much as I have done with my Mac experience, I hope to share some of my learning process about Ruby on Rails as I go along, from the perspective of a .Net / C# / Visual Studio guy. I know I have a fair number of readers that are using Visual Studio now on their Macs so hopefully you'll get some value out of this.

Who knows though - it may be a very short series if it doesn't go well.

Comments

Anonymous said…
I'm not sure of the details and will probably be digging into it more, but it seems text editors can integrate with XCode somehow, so you can still use XCode and TextMate together if you want.

I discovered this the other day when I ported a tiny Windows C++ command line app over to my Mac with XCode. I had been just using the built in text editor, but had some other task come up that made me open TextWrangler. When I went back to XCode and tried to build, it was asking if I wanted to save some unrelated file I had left unsaved in TextWrangler.

Sorry that I don't know the specifics of how this works or how it's configured, but it might be worth looking into. I'm still debating what text editor I want to use for coding on the Mac myself.
Anonymous said…
@tom: In XCode's Preferences under "File Types" you can tell XCode to open external editors for each type of file that can be opened. For example, .XIB files are opened in Interface Builder based on the option in XCodes preferences.

David, I have been curious about Ruby and Ruby on Rails ever since I first heard about them. Problem is, I don't know what they would do for me as a developer. I've never done any web based development and don't really know of any practical uses. I suppose if I made a shopping list program that used a desktop client to edit the database, I could use a web based app to access the list when I was actually out shopping. Is that pretty much the kind of thing Ruby on Rails could do for me? (Not that I have any plans to do this)

I'm more an applications programmer myself, although, I have moved away from that in recent days and started doing software testing professionally. I suppose this is why I am still looking for a job instead of working right now. :(
David Alison said…
@Tom: It's funny, having been using a complete, integrated IDE for so long I'm actually enjoying popping into the command line now and using a text editor as opposed to a full blown environment. I don't feel like I'm having my development platform masked for me.
Anonymous said…
Are you giving up on the Agile… book for now? I too am just starting with it. If so please publish the differences.
David Alison said…
@Vesperdem: Ruby on Rails is really a highly targeted development tool. You are only going to build web based applications and by far the biggest advantage to it is the speed with which an initial application can be developed.

There is a fundamental shift in the way applications are being deployed, with web based alternatives becoming very attractive to companies that don't want to deal with the local client side applications. Unlike tools like Visual Studio, which can target a great many different classes of applications, RoR is just for web sites.
David Alison said…
@Anon: you have two choices: roll back Ruby on Rails to 1.26 and follow along with the book or keep it at 2.02. If you decide to keep it at 2.02 then you will need to either use Plugins to replace the dynamic scafolding and paging that's been removed or you can do what I did and use a different tutorial for that portion of the book.

I used Sean Lynch's excellent tutorial - it builds basically the same application that's in the Agile Web Development with Rails book (Depot). Keep the book handy and follow along with that too.

I say this like I'm an expert but the reality is I'm just learning this too. Hope it helps!
Anonymous said…
The fairleads article should help. I hadn't seen it, but then I don't know enough to know to search for what I need. Makes sense for me to stay with v2, but then the documentation is thin.

Anon
Andy said…
I think you're doing Rails a bit of a disservice calling it 'simple'. I've done a fair bit of rails development, and (as with Ruby) most times I've though "I wish there was a way to do X" I've found that there already is; and usually Y and Z too...

I'd definitely recommend TextMate as the tool to use : get used to it's tab completion shortcuts and you'll save a load of typing.
Anonymous said…
Visual Studio has me spoiled -- that's the number one reason I find it difficult to start using any non Microsoft language - there isn't another IDE that compares. Textmate seems so vanilla in comparison. I just started reading a new book on Mac development so I'm starting to look into the Xcode tool.

However, the main reason for my post is that I notice that you actually bought books for learning RoR. I used to be the kind of guy to buy at LEAST one technical book a month. This gets to be a bit expensive and it really takes up space on the bookshelf (and the once a year garage sale just doesn't get rid enough of the old ones!) I started using O'Reilly's Safari online service. I haven't bought a technical book in two years and I have access to thousands of books and VIDEOS for the same price as a book a month. In addition to the convenience of not have tons of books laying around - you get full-text index searching of their entire library.
Anonymous said…
Looking forward to reading about your Ruby on Rails learning experiment.
David Alison said…
@Andy: You read simple the wrong way. If I had replaced that word with complex would that have made it better? I call RoR simple because with a couple of command line entries I have a complete applications framework built that can read and write data to a database using basic forms. Simple in that sense was a high compliment. Keep in mind that I'm also still learning this so I haven't dug in too deeply yet.

@JTaylor: I hear you on the IDE front - it makes it a challenge to try and go back to the "old way" of development with different components for each phase. TextMate, especially with the helpers it has for Ruby work, takes it pretty far. By far the thing I miss most is the function finishing (IntelliSense).

Thanks for the great tip on O'Reilly's service - I had not heard of them before. While I've been buying quite a few technical books lately I don't know that paying on that model would work for me. Plus I'm a dinosaur that's still addicted to the dead tree form for reading. I do like that idea though...
David Alison said…
@Michael: Thanks for the links - I found your site earlier when I was trying to overcome some of my objections for using Ruby on Rails. The issue of scaleability was a major concern for me but your article on the topic was a big help. In case anyone else is concerned about that you should read Michael's article on the topic:

Can Rails Scale? Absolutely!
semioticmonkey said…
Same here with Agile Web Development with Rails book. It is a good book for the starters but you have to use Rails 1.2.6 (at least) if you want to follow along without not too much headaches.
Anyway, after bought it, i bought
Packt Ruby on Rails Enterprise Application Development too and i mainly used ti to step into ROR.
http://www.packtpub.com/Ruby-on-Rails-Enterprise-Application-Open-Source/book

I suggest
Advanced Rails
http://www.oreilly.com/catalog/9780596510329/
and
Pro Active Record: Databases with Ruby and Rails
http://www.apress.com/book/view/9781590598474
for a more detailed view of ROR development.

I use TextMate and Terminal for all my needs. Use the svn and sql bundles for managing projects and databases within TM. You don't need Xcode for advanced stuff. TM is capable of this and more.

Welcome aboard ROR, David. I hope you'll have fun.
David Alison said…
@semioticmonkey: Thanks man - I've got some other books I'll be talking about as well, though I don't really want to write about them until I've been through them. I decided to stay with Rails 2.0 and just gut through the differences that are in the Agile Web Development with Rails book and have found that to be a pretty good trade-off. When I encounter something that doesn't work as listed in the book it makes me dig a little deeper to understand what the problem is and I'm gaining a better knowledge as a result.
If you're just starting out with Rails, look also at the Seaside web framework (http://seaside.st). It's got all the advantages and then some, the most important of which is that it's both faster to develop with *and* faster to execute on similar hardware (some benchmarks showing between double and 10 times the performance). Seaside was developed by Avi Bryant after he tried a similar framework with Ruby. Definitely worth looking in to.
David Alison said…
@Randal: Thanks for the link - I'd never heard of that platform before.
Travis Jeffery said…
For anyone learning I'd stay away from any of the crap Dave Thomas writes. Shit like putting modules in models, weird and confusing variable names, and bad design aren't going to teach you anything positive.

Without a doubt the best book out there right now for RoR is "The Rails Way" by Obie Fernandez. It includes Rails 2.0, and goes in-depth in just about any thing you could want to know about Rails. When you finish that book you're going to know the right stuff and know it well.

And if you want to know more about Ruby, get "The Ruby Programming Language" by Matz and Dave Flanagan.
semioticmonkey said…
@Travis Jeffery
Tnx for suggest the Obi Fernandez book. I read some positive review about it and all of them touting it as 'an expert guide'. Not for someone on his way in the ROR world.

http://www.rubyinside.com/the-rails-way-by-obie-fernandez-679.html

http://www.amazon.com/Rails-Way-Addison-Wesley-Professional-Ruby/dp/0321445619

I'd like to know your opinion in the matter.
David Alison said…
@Travis: I gleaned that already in scanning through the book. Looks like I'm going to end up using it more for syntax than coding styles. I purchased two other books that I haven't cracked open yet because they are targeted at non-n00bs, which I'm still in the n00b category. The are The Rails Way by Obie Fernandez and The Ruby Way by Hal Fulton. Both came highly recommended. I'll talk a little more about them as I go along.

Travis, this is an open learning experience for me. If you have specific suggestions don't hesitate to shout them out - I appreciate it man.
Travis Jeffery said…
I would recommend looking at as many screencasts as possible, PeepCode's are really in-depth and easy to understand for newbies, RubyPlus.org has some good ones, and there's Railscasts for more for intermediate users.

If you go to the iTunes store and search Ruby on Rails there are quite a few podcasts some of them are for more advanced users and talk about news in the Rails community but others are for good for learning as well.

And then the forums, railsforum.com is probably number one and there is also the ruby-forum.com.

So just throw yourself in head-first building something you want and when you hit a wall go find the fix.

@semioticmonkey once you've got the basics, MVC architecture, how to move data back and forth from the model to the controller to the view and vice-versa then go ahead and get Rails Way. It's a little difficult but so will every other book at first and at least with this book your effort won't be wasted.
David Alison said…
@Travis: thanks for the great tips. I'm determined to take a different approach with Ruby on Rails, not jumping in to building my product just yet because in all likelihood I'll build it as if it were a .NET based application. I really want to get a solid handle on the MVC model, which is very different than .NET's event based model for UI work.

Ruby is not at all complex for me and is quite easy to learn - it's the syntax that's kicking my butt right now. I'm also really interested in the unit testing model being part of the development process - I've always just done that after the fact, more in the debugging phase when something breaks down. That said, I have some crappy programming habits I've fallen into that I need to relearn and I'm using Ruby as an excuse to that as well.

Again, thanks for the help Travis!
semioticmonkey said…
@Travis: You sold a book! :)
Seriously, tnx for the direct input. I've already ordered a copy of it on Amazon.
Pretty impressive index, i must say.
SamW said…
Coding is fascinating -- and fun; but I am hacking away at Python and com-based C and C++; Python because it is powerful and easily cross-platform, C++ because I have a masochistic streak. Ruby is disturbingly cool. Note that Google's SketchUp uses it as its scripting language. As to Mac platforms I have always been interested in Objective C -- how that version of C has been incorporated into the BSD underpinnings of the latest Mac OS. PHP seems to be one of the hot languages for web programming; but it seems to me too much like coding HTML prior to CSS. I like as complete a separation in functions as possible. But, then, I am probably entirely wrong, should have bought a Mac 20 years ago, and never got confused by Perl, Python, C, PHP, Ruby, etc.
--Tourist in coding-land
Nice post keep on posting more.
It was good blog i know ruby on rails is a really simple framework and model for building Web applications very quickly and easily. thanks for this articles.

Popular posts from this blog

Keyboard vs. Mouse

Some cool Firefox add-ons

A hardcore Windows guy gets a Mac