Static scaffolding in Rails2

Hi,

I am looking for a replacement for the static scaffolding of Rails 1.2.x. Rails 2.x has stopped proving the scaffolding.

Specifically I want to generate a controller from an existing model and I want to have and freeze the code. Basically I just want to generate a scaffold on which I am going to build my app (back and frontend). It is also an example of code (I am still a newbie). In 1.2.x the command was : script/generate scaffold post blog/post

I quickly checked active_scaffold and streamlined. But I am not sure they allow accessing the actual view code (rhtml/rjs/ruby), do they ?

Is static scaffolding completely deprecated, for everybody ?

H

You can type: ruby script/generate scaffold --help in your rails application directory and you'll get the information on scaffolding. Only dynamic scaffolding is gone in 2.0 to my knowledge, not static.

scaffold in Rails 2.0 is what was called scaffold_resource in Rails 1.2.x. It generates a static scaffold using RESTful design.

Michael Slater www.BuildingWebApps.com

OK but can you generate a restful controller from an already existing model ?

From what I understood it is not possible but I want to be sure.

H

Michael Slater wrote:

Yes, you can. script/generate scaffold MyModel --skip-migration

Include --skip-migration to bypass the migration generation (you won't need it since you've already got the model). This will give you the scaffold but the views themselves may not auto-populate with the fields.

You could also "script/generate controller MyModelsController index show new create edit update delete" This definitely will not get the auto-layout stuff, but it will stub things out for you. If you do this you'll need to add your own map.resources statement to routes.rb.

HTH, AndyV

Thx for the answer, I gonna check that. But the part I liked in the controller generation was in fact the form generation. It helps a lot the newbies (newbie even in html) like me. I am surprised it has been deprecated. I am still looking for it in AS or streamlined.

H

AndyV wrote:

Well, if you just want the forms, I made a generator to make that available in Rails 2.0

gem install scaffold_form_generator

See this for more info:

http://scaffoldform.rubyforge.org/

It does NOT generate controllers… just the views for new and edit, along with the partial.