Intro to Rails (using v. 2.0)

December 7th, 2007

Larry LOVES Ruby on Rails

As some of you know, when I’m not working I’m taking classes in Information Systems at UCF. One of the classes I took this semester was Web Systems II, which is essentially a server-side course that focuses on ASP.NET development.

One particular assignment was creating a “Category Code Manager”, which I had never heard of previously. I think the professor made the term up, but the concept is simple nonetheless. There are categories (ie: fruits) that each can have many codes (ie: apples, oranges). I think the purpose of the assignment was to get used to working with foreign keys, and building dynamic drop downs as a tool to display this sort of relationship. Another gotcha is that the categories can have parent categories.

The class had a participation grade that I must have overlooked… Needless to say that didn’t bode well for me, so I created this screencast as an introduction to Ruby on Rails (beginner level) using the new Rails 2.0 (final source code included.) I tried to follow best practices where possible (ie: TDD), and covered the topics of:

  • Database agnosticism & environments
  • Using rake to create databases, and to run
  • Scaffold generator
  • has_many & belongs_to relationships within ActiveRecord
  • The interactive Rails console
  • The new integration of the ruby debugger, and a drop of live metaprogramming
  • Test Driven Development with Test::Unit
  • Intro to REST’ful architecture within Rails

But, I left some things out to avoid making the screencast even longer, and avoid it being confusing for beginners. Just so you all know, some changes I would have made include:

  • Create some helper methods for things like populating the select tags
  • Use nested routing (I did this first, but renaming all the named routes, having to explain the routing, etc made this too complex for a beginner video)
  • Use RSpec for testing (RSpec’s scaffold uses mocks and stubs, which are just a little too much to explain when already introducing all of Rails and testing)
  • Use a REST’ful abstraction plugin (we developed an internal one at work, but unfortunately we haven’t been able to open source it yet… until then check out make_resourceful)
  • Use the ObjectMother pattern for creating objects during tests

Enjoy the screencast!

One Response to “Intro to Rails (using v. 2.0)”

  1. McKenzie from Web System II Says:

    Good job… real professional work…

Leave a Reply