I recently started with the ‘Agile web development with Rails’ book by pragmatic programmers after having some early experience with rails but wanting a more structured approach.
I’m happily following the book when they ask me to make a controller admin so I can edit the standard CRUD product model I already created. According to the book I should add the line ‘scaffold :product’ to my admin_controller and it should run like a charm. Well, my rails only says: “undefined method `scaffold’ for AdminController:Class”.
I know he’s using an older rails version in the book, like 1.8 or something, and I know how to run a normal scaffold but not how to make the admin_controller inherit all the juicy CRUD details from Product like the books statement suggests. I tried copying all the views and the scaffold generated controller code from the product_controller to admin and that works fine, but I was really wondering what the proper way to do this is.
My admin_controller:
class AdminController < ApplicationController
scaffold:product
end
The functionality you mention, dynamic scaffolding, has been removed in Rails 2.
I recommend using regular scaffolding and going from there if you are new to Rails. Once you get some more experience it will be easy enough to quickly brew your own controller actions.
There are some alternatives to dynamic scaffolding which may be helpful for quick prototyping or if you develop a lot of the similar functionality: