I've been testing out the behavior of Komodo's Rails Project Template with Rails 2.0, and found that scaffolding breaks with this output:
exists app/models/
exists app/controllers/
exists app/helpers/
exists app/views/movies
exists app/views/layouts/
exists test/functional/
exists test/unit/
wrong number of arguments (1 for 2)
library --skip
exists app/models/
exists app/controllers/
exists app/helpers/
exists app/views/movies
exists app/views/layouts/
exists test/functional/
exists test/unit/
wrong number of arguments (1 for 2)This happens even when I run the command in the command-line, with the usual model and controller name arguments.
It turns out that the version 1.* scaffolding has not only been deprecated, but the meaning of the command has changed with version 2.0. Instead of supplying the name of an existing model, and a new controller, you supply the name of a new model, and its fields, and it will generate a model, migration, and a rest-based controller.
The workaround is simple, and currently requires no change. To build a Rest-based resource for your Rails 2.0 project, click on the "scaffold" tool, give the name of the model as a capitalized, CamelCase singular name ("Movie", "Grocery", "Blog"), and for the "library" field, enter the model attributes instead ("name:string year:integer rating:float" for Movie, "name:string quantity:float price:integer" for Grocery, etc.).
A later version of the tool will check which version of Rails is being run, and adapt accordingly.





Do you have to list all attributes of the model, or does this let you create a scaffold selectively? Also, what is the address for the scaffold once it's created? According to the tutorial, it should be http://localhost:3000/library, but clearly it's not going to get the library name now.
:Nate Dickson
The changes are not backward-compatible, unfortunately.
I couldn't resist showing some of the benefits of
the new version, while showing how to get going...
The new site for the scaffold-resource-generated app is:
Because the scaffold generator is now restful it gives you
the following URIs:
And you can add a ".xml" to the end of the URL:
Now add this line to the show method in movies_controller.rb,
under the format.xml line:
format.js { render :json => @movie }Here's what the JSON Rails returns would look like.
Hope this gets you going. I plan on updating the toolset and
screencast to work with Rails 2 soon now.
You'll have to manually update the views, but scaffold-generated
views have always been intended to be just scaffolding, and not
the final product.
As I showed above, I find the controllers that the new
scaffolder generates to be pretty cool.
You don't have to list all the attributes in the scaffold command.
The scaffold command will auto-generate the created_on and updated_on
timestamp fields for you automatically. You can bypass that by
running the command from the command-line, like so:
Later on you would use the
generate/migrationandmigrate/db:migratecommands to add more attributes,just like in 1.x.