Ruby on Rails questions

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?

I’ve developed a similar MVC paradigm for my own web apps, but Ruby on
Rails seems like it is a little more polished. I do have a couple of
questions. Forgive me if the answers are obvious. I consider myself
somewhat of a Ruby novice still. I’ve written plenty of code in Ruby
but only in the conventional ways of the type that are explained in say,
Programming Ruby, not getting into more extravagant features like using
design patterns to change the actual OO features that is available in
the language. 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?

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?

Thanks,
Carl Youngblood

Carl Youngblood wrote:

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?

Never mind about this question. I suppose it uses some version of
eruby. Having never used this (I use fastcgi instead of mod_ruby), I
forgot about it.

Thanks,
Carl

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 :wink:

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

Carl Youngblood wrote:

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?

I’ve developed a similar MVC paradigm for my own web apps, but Ruby on
Rails seems like it is a little more polished. I do have a couple of
questions. Forgive me if the answers are obvious. I consider myself
somewhat of a Ruby novice still. I’ve written plenty of code in Ruby
but only in the conventional ways of the type that are explained in
say, Programming Ruby, not getting into more extravagant features like
using design patterns to change the actual OO features that is
available in the language. 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?

I think it is described in the pickaxe but the idea is that since every
class is a Class which is a Module you can add instance methods to
Module and they can be accessed inside all class “scopes”:

class Module
def looks_like_keyword(*args)
p args
end
end

class MyClass
looks_like_keyword “a”, :a # => [“a”, :a]
end

Hope this helps,

/Robert

Is RoR somewhat like CGIKit, but with more automation via reflection?

···

On Tuesday, 25 May 2004 at 4:24:29 +0900, David Heinemeier Hansson wrote:

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?


Jim Freeze
THE LESSER-KNOWN PROGRAMMING LANGUAGES #13: SLOBOL

SLOBOL is best known for the speed, or lack of it, of its compiler.
Although many compilers allow you to take a coffee break while they
compile, SLOBOL compilers allow you to travel to Bolivia to pick the
coffee. Forty-three programmers are known to have died of boredom
sitting at their terminals while waiting for a SLOBOL program to
compile. Weary SLOBOL programmers often turn to a related (but
infinitely faster) language, COCAINE.