Ruby on Rails 2.0 – Scaffolding is Gone!!!
Friday, May 9th, 2008Scaffolding is gone? Well… sort of.
In Rails 2.0 the method scaffold is gone from the ActionController::Base so there is no dynamic scaffolding.
So what is a developer to do?
You could uninstall Rails 2.0 and downgrade to an older version of Rails, but what is the fun in that?
Our hats are off to Leonardo Borges for saving us from Rails 2.0 frustration, or worse – starting from scratch.
Now that the dynamic scaffold is gone, we’re left with the static one.
Ok, let’s try it then:
$ script/generate scaffold contactAnd it won’t work again!
At the end of the output, you will get something like this:
Another migration is already named create_contacts: db/migrate/001_create_contacts.rbIt really means that if your model is meant to be used by a scaffold, you better generate it in the same line. It will fail, afaik, if the model previously existed. Destroy your model and controller, and execute the following:
$ script/generate scaffold Contact name:string email:stringDone! Just run your migrations, startup your server and your new scaffold in rails 2.0 will be working gracefully!
