Ooh thanks I love these.
1. What are migrations and why are the useful?
Refactoring Databases is bloody hard. There's a book about them, which
I haven't read yet. If I wrote it, it would say for each new DB
version you must write a script that migrates live customer data
forward and backwards. So Rails provides that out of the box (and, as
usual, with only 75 lines of code, not the 75,000 that Brand X
2. What is AJAX all about?
Decoupling parts of your web page from each other so the server can
update them indepentantly, without forcing a page refresh and loss of
3. How does Rails apply the MVC pattern?
Rails encourages MVC by enabling a 3-layer architecture, with
different available facilities in each one. True MVC is up to the
programmer, just as you can still write non-OO code in Smalltalk by
cramming everything into one long method.
4. How do you know when to write unit tests, functional tests, or
Uh, you write them and see.
Better, you prefer unit unless you need the extra test capabilities in
the functional library; again you only move up to integration if you
need its capabilities.
This matches the rationale for placing code. Put it in its nearest
model unless it needs a controller's abilities, etc.
And if you invent a new system of your own, it should have test suites
that match its architecture.
5. What are the different ways of storing sessions with Rails?
Cookies, the Session variable, or as IDs that go round-trip thru the
view and into the database, as hidden fields.
6. In Rails, how does a given url result in a controller method being
The dispatcher calls routes.rb, which deconstructs the URI (not "URL")
and generally matches controllers and actions by name.
7. What is REST all about? Why is it an important design pattern?
That's on my "see how long I can successfully ignore" list.
1. What are common methods used from the Enumerable module?
Ruby is so easy to use that I have successfully placed that one on my
"ignore" list. Uh, something to do with overloading the spaceship <=>
operator so you can sort automatically.
2. How do you subclass and override methods?
You subclass classes and override methods. The keyword def is a
command, not a delimiter, so a class responds to messages with the
last-declared method with its name.
3. Describe a problem you solved by using missing_method appropriately.
I used Builder::XmlMarkup, and it just seems to read my mind. Its
verbosity is directly comperable to the XML or HTML that it replaces.
But it's easier to refactor!
4. What are singleton methods all about?
Sometimes when you put the barrel in your mouth you just can't reach
the trigger, huh? They are about making your code a pain in the balls
to unit-test. Resist the temptation of their syntactic sugar!