What happened to scaffold in Rails 2.x?

Rant time! This one may or may not ruffle some feathers, but frankly I don’t care. I’m probably late to this party and missed out on all the big flame wars seeing how 2.0 was released at the beginning of December. Still, this kinda pissed me off. I just wanted to ask the Rails team what exactly was so horribly wrong with the scaffold method that they had to rip it out in 2.x release?

Let me back track a second. Some of you probably don’t have a clue of what I’m talking about here so let me paint you a picture here. This is how just about every Rails book and online tutorial starts the same. First thing they teach you is to create a Rails app, create the database and then set up a model and a controller for some database table (let’s call it things).

Then, inside the things_controller.rb file you were supposed to do:

class ThingsController < ApplicationController
  scaffold :thing
end

This would generate an invisible dynamic scaffolding that would take care of basic CRUD operations. The idea was to start clean, and then slowly chip off the scaffolding by overloading it with your own content. For example, once you define index method in the controller, and and index view the listing is no longer handled by the scaffold.

At any point of development process you could have dropped this single line in any of your controllers to get bare-bone basic functionality on the fly. It had that wow factor, that was bringing all the boys to the yard, like the milkshake... Or something like that. My point is was that it was easy to use, did not clutter your codebase with auto-generated gunk and every fucking Rails tutorial on the planet was using it.

Do you know what happens when you try to use the scaffold line in the current 2.0.1 release of Rails? First you get an error message. Then a little guy jumps out of the closet and kicks you in the balls, steals your wallet and then jumps out the window. Or maybe that's just happened to me. Either way, it's not a pleasant experience.

At first I thought that maybe I just can't spell scaffold. But no - it just no longer exists. I actually had to google it cause I had no fucking idea. They just riped it out and junked it. Yay backwards compatibility. I can't wait to see what useful features you will remove in Rails 3.0 to fuck up my work flow! Wohoo!

I know that scaffolding was just a neat feature which really didn't influence how a deployed rails application performs or behaves. I know it was not essential, and I know it was only useful in the very early stages of development. Blah, blah, blah. Still, why remove it? The official release post doesn't even mention this change.

I looked through some mailing lists and forum posts, and I on every single one I saw pompous jackoffasaurs taking turns enlightening masses on how only idiots used scaffold method, that it was abused, that it was a "crutch" and how the new way actually forces retards to look at the code. Really? You are serious?! They removed it out of goodness of their hearts to save us heathens from our wretched scaffolding practices? Thank you there, Dijkstra - why don't you write me a "considered harmful" essay while you are at it? Geezz...

So I'm asking - why was it removed? Perhaps someone can give me an objective, unbiased and non-elitist analysis on why it was not fit for 2.0. I just want to rationalize this. I want to find some sort of justification. And no, "cause u were doin it rong" just doesn't cut it for me. Give me a benchmark showing that dynamic scaffolding is slow, tell me about security concerns, about compatibility migration issues. Tell me how how the "new way" improves the work flow, improves coding practices and is generally better. Give me something. I might buy it - who knows. I just couldn't find any explanation like that anywhere out there. Everyone is simply viciously bashing n00bs and passive-aggressively flogging anyone even daring to ask about the scaffold method. :evil:

You can naturally still scaffold in 2.x but only via code generation. And when you do it, the script generates everything including the model, controller, views and database migrations. In fact, they dumbed it down to the point where it no longer even looks at database to dynamically detect the correct fields and data types.

The 2.0 way is to scaffold first, then create a database. The script generates a migration based on the list of fields you specify as arguments. Same fields are also used for the views. If you don't specify any fields on the command line, you will get a half-assed views that do nothing. Nice thing is that if you do specify correct fields on the command line, you end up with a complete set of controllers, views, migrations and etc. All you need to do is to run the migration script, then fire up the server and you are good to go. It does make sense conceptually - after all in real world you put scaffolding up before you start building. Maybe this is a superior approach, but I just don't see why we can't have it both ways.

Needless to say, I'm a little bit disappointed with this change. I can only imagine how confusing it must be for new Rails users who are trying to follow a simple tutorial from a book. I was confused as hell for a minute there, and the whole thing left me a bit turned off to rails. It's a great framework, and I'm still planning to use it on a few projects, but this whole scaffolding debacle really did a great job of dousing and subduing my enthusiasm. Maybe it's for the better and it will allow me to look at RoR objectively instead of jumping on the "OMG this is FANTASTIC!" bandwagon.

Wantonly breaking backwards compatibility on a whim and without any justification is a cardinal sin of software development and frankly it scares me a bit that they chose to commit it. I'm not saying breaking backwards compatibility it's always bad. Far from it - sometimes you need to ditch old code if it is holding you back. And that's perfectly acceptable. But fucking up chapter one of just about every published Rails book, and every single online tutorial in one swooping move is not a good thing.

Since the begging of December people have been reading the now outdated tutorials, and scratching their heads trying to figure out why Rails is not working. It's a good thing everyone loves Rails these days. I bet most people will forgive and forget, but I think they really shot themselves in the foot with this. :P

[tags]ruby, rails, ruby on rails, ror, scaffold[/tags]

This entry was posted in Uncategorized. Bookmark the permalink.



7 Responses to What happened to scaffold in Rails 2.x?

  1. Jason Arora UNITED STATES Mozilla Firefox Windows says:

    Great post – I agree with every single point you’ve made.

    I was very disappointed to see scaffold removed and replaced with a “generate scaffold” command which adds like 100 files right off the bat.

    For a web framework that “makes web development easy”, they sure did a good job of frustrating lots of future Rails developers who are just starting.

    I would really like to see scaffold added back to official release, but if it hasn’t happened yet then I doubt it will.

    Jason

    Reply  |  Quote
  2. madra UNITED KINGDOM Safari Mac OS says:

    spot on! – i am one of those ‘rails newbies’, who’s been methodically working through the sitepoint book, only to run into this fucking brickwall after 140 pages. this is about the fourth time i’ve promised myself i’ll grit my teeth and see learning this rails thing through to the bitter end – and every fucking time *something* comes up which is either completely undocumented, documented wrongly, or involves completely re-installing half the software on my computer just to get rails starting to think about considering the slightest possibility of maybe working a bit.

    i’m beginning to think the ‘easy’ adjective, generally applied to learning rails is some kind of twisted joke.

    Reply  |  Quote
  3. Luis EL SALVADOR Mozilla Firefox Windows says:

    so there’s no way to ask politely rails to read the table and the columns? I come from a Java world and let me tell you that this approach sucks as much as all those java crap.

    Reply  |  Quote
  4. Colin W UNITED STATES Internet Explorer Windows says:

    [quote comment=”8040″]spot on! – i am one of those ‘rails newbies’, who’s been methodically working through the sitepoint book, only to run into this fucking brickwall after 140 pages.[/quote]
    I have to say, I couldn’t have said it any better. What were they thinking?!

    (I support obama, too.)

    Reply  |  Quote
  5. query_developer UNITED STATES Mozilla Firefox Windows says:

    You’re right. Unfortunately more has changed than just removing dynamic scaffolding. I’ve spent the last three years developing complex queries, some graphical.

    Now, after a week of struggling with Rails 2, I’ve discovered that I can’t reuse any of my code. Adding additional def’s to the scaffolding and adding new views simply doesn’t work.

    Many of the important plugins don’t work either. For example, the logingenerator worked and could be easily modified to include permissions.

    The lack of backward compatibility is a slap in the face to those of us who have spent so much time developing the code that enabled the databases to do amazing things.

    Reply  |  Quote
  6. Luke Maciak UNITED STATES Mozilla Firefox Ubuntu Linux Terminalist says:

    Wow! Damn, I’m just sort of dabbling with it. Guys like you are the ones who got totally shafted by this change.

    I thought that I’m basically just an annoyed n00b and that the community at large accepted these changes. Now I’m wondering if Rails 2 created some sort of schism, fracturing the Rails community in two.

    Are there enough people hating the new Rails to fork the code and back port the good features from Rails 2 without breaking the old behaviors?

    Reply  |  Quote
  7. Pingback: RoR – zapiski dyletanta. | socjolocja UNITED STATES PHP

Leave a Reply

Your email address will not be published. Required fields are marked *