I’m really interested in seeing Ruby on Rails. As far as I can tell
it doesn’t appear to be available yet. Will it be available as a
standard ruby module, open source and everything?
Thank you and no, it’s not available yet. It’ll be available under an
open source license when released (BSD/Ruby-like).
Rails is really a couple of things, though. It’s composed of two
different sub-projects, Active Record (model) and Action Pack
(control/view), and a lot of glue to bind these together seemlessly. So
in its final version there’ll be a Rails release containing everything
needed to build successful web-applications (such as Basecamp[1]) and a
individual release for each of the two sub-projects.
Instiki is already using an older variant of the Action Pack, but
doesn’t use Active Record. James Buck and others are using Active
Record in isolation to build projects without the Action Pack. So
that’s the reason for the otherwise slight confusion in three different
projects. I hope I’ll be able to explain it clearly when its time to
release things.
Regarding time, I’m natural hesitant to provide anything concrete. No
reason to setup future disappointments. But I will say that the Active
Record is very close to release. It’s already documented in total,
fitted for use with three different databases, and ships with a bunch
of examples. So it’s just the last stretch of spit and polish that’s
lacking for the Three-Quarters release (0.7.5).
With regard to the entire framework, I’m tentatively shooting for a
release of some kind during late June. There’s a range of projects
waiting to start using Rails and I’ll be presenting again at the
Building of Basecamp[2] workshop also in late June. So there’s a bunch
of external pressure to get to a release out combined with my
graduation in early June should at least open a window of possibility.
Don’t hold your breath, though – as adviceable for any project, open
source or commercial.
So I was confused when I saw things in the Rails model classes like
belongs_to and has_many. These look like new language keywords. How
is this done?
Ruby can call methods during class or module evaluation. So what looks
like keywords are actually just class method calls made during the
class evaluation. It’s the same “trick” used by Ruby’s own attr_*
accessor macro-like methods. It’s a really powerful feature and one of
which I’m most fond of with Ruby.
These method calls are then used to dynamically extend the class under
evaluation based on data gathered through introspection.
This is why Rails is able to shed the bulk of configuration files that
are used by other conventional frameworks (especially in XML-happy Java
land). This also strips the compilation step, so any change you make to
model, controller, or view is instantiously visible. (You can see how
much this means to productivity in the second hour of the video
referenced below).
I also was wondering how the views were implemented. How are the
embedded ruby tags parsed? Does the code use eval or is there a
better way?
Action Views uses ERB, which is an all-Ruby version of eRuby, which in
turn is just what you describe: embedded Ruby. On top of this is
sprinkled a helper system, so you don’t litter the views with tons
scriplets. The helper system provides a lot of default behavior for
standard web-applications. It’s kinda like tag libraries from Java
land. Just without all the overhead and wiring that makes people use
Java scriptlets in the first place.
There’s a couple of presentations available at the
http://www.rubyonrails.org/ site and a two-hour video at
http://www.loudthinking.com/arc/000232.html.
I really do hope that June is the month were I put my code where my
mouth is and deliver. Real Artists Ship, I’m told
fn1. http://www.basecamphq.com/
fn2. http://www.37signals.com/workshop-062504.php
···
–
David Heinemeier Hansson,
http://www.instiki.org/ – A No-Step-Three Wiki in Ruby
http://www.basecamphq.com/ – Web-based Project Management
http://www.loudthinking.com/ – Broadcasting Brain
http://www.nextangle.com/ – Development & Consulting Services