Beyond Scaffold

Most Ruby on Rails books and tutorials, or at least all the ones I
have read, start with a simple application with modest requirements
and show how to create and migrate the database and how to generate a
scaffold based UI.

This is all well and good, but when I try to move beyond scaffold to
the web application UI that I want, I quickly find myself mired in a
swamp up to my eye-balls.

Or, to mangle another metaphor, working though the examples and
tutorials is like watching a magic show, but I need to figure out how
the tricks work.

What I am trying to create (as a learning exercise and not a paying
gig, thank God!) is yet again another ToDo list application with some
very non-scaffold like elements including:

  1. A two columns welcome screen with login on the left and register in
    the right. Successful completion of either of these leads to …
  2. A three column working screen with the user’s ToDo items organized
    as a tree on the left, a list of the ToDo items under the selected
    element in the center, and an always open form on the right that can
    be used to add or edit ToDo items at any time. I will eventually use
    JavaScript to set the initial focus on the first field in this form.
  3. In general, all lists will be of incomplete items in inverse order
    by priority where priority is not a field in the database but rather
    computed from other fields in the record.
  4. Complete page refreshes for now, but eventually AJAXed.

So far, I keep bumping up against redirects that don’t redirect or
redirects that do work, but display the layout for where I came from
instead of where I went to.

Clearly, there’s stuff going on that I didn’t fully internalize by
working through the examples. I come from Java/Swing background where
I wrote all the glue code that help the various API calls together and
I bring zero experience to this kind of framework, where the man
behind the curtain reaches out and runs little snippets of code I
write, code I didn’t have to write, or code that gets generated based
on hints that I configure into the code (has_many, acts_like_tree,
etc.).

To mange a final metaphor, I’m finding it heavy sledding.

What I would love to find is a walk-though of a RoR application
describing how and why the flow of control is transferred between
Controllers (including helpers), Models, and Views (including Layouts
and Partials). I would also love to know how render and redirect calls
effect (and don’t effect this process) and how stuff gets into and
goes out of scope.

Does anyone have any suggestions where I might find a document of this
nature?

I’ve just gone through “Agile Web D. with Rails.”(Pragmatic
Bookshelf) in an online version that covers rails 2.x(NB printed
versions of the book I have seen for sale do not cover ver 2.x, so I
would not recommend them). The first part of the book is a rather
involved tutorial that does show model/controller/view/helper/partial
interactions quite well. I have not found anything yet that shows
complete functional examples of all types of model/table relationships
so that as I try to create has_many_and_belongs_to_many models I
struggle with what the generators do and what I need to do.

I am still totally confused and suffering from the novelty of ruby and
rails, especially since so much functionality is not visible in code
but must be read about in documentation. Therefore you might want to
discount my endorsement of the book. It is, however, the first ebook
that I found that actually functions with ver 2.x and does show at
least an example of each of your areas of concern.

I feel I am painting a house with a 1" brush, mowing a lawn with
sissors, and beating an egg with a toothpick.

Sam

Just to clarify–do I take that you’re well comfortable w/basic HTML/css
(or tables I suppose) for doing layout etc.? You could if you had the
time hand-write static html pages to get the effects you want, you just
haven’t been able to figure out how to get rails to generate it for you?
(As someone whose HTML/css is pretty sketchy, it seems to me that rails
wants a fair bit of mastery of that material. It saves you from typing,
but not understanding it :wink:

I agree w/Sam that AWDWR 3rd ed has a decent description of how the
models/controllers/helpers/views interact (probably the earlier eds do
too–not sure). I’d also highly recommend Ruby For Rails, which I
think covers a lot of what the magic pixies seem to be doing behind the
scenes. (It’s a tad bit outdated on the rails front, but still very
very worthwhile.)

In general tho, I’d recommend just slogging through a bit at a time.
Start simple. You mention having a problem w/redirection & layouts.
Put together a page w/a select tag & a submit button & try redirecting
to minimal pages w/different layouts based on the value of the select.
If it doesn’t work, post your code & we should be able to help you
figure out why. If it does, build from there. It’s slow going to
start, for sure. But it sure does pick up as you learn the conventions
& such…

HTH,

-Roy