views:

550

answers:

1

I am playing with the scaffold feature of rails in Netbeans 6.5. Right click->Generate gives me a menu that allows me to create the scaffold but asks for "attribute pairs". I have some tables with quite a few columns and would rather have the scaffolded pages include them all instead of specifying each one individually. Does anyone know how to do this within Netbeans?

A: 

Do you mean you want to scaffold the all the tables all at once? I think the script doesn't do that.

But you can indeed generate a table with all the required columns by specifying all the attribute pairs. I don't use Netbeans, sorry, but you could specify them on command line this way.

Each attribute pairs is a column in your table. For example, this command line

./script/generate scaffold blogpost title:string body:text

generates a controller, a model and some views with the name of blogpost. blogpost would be your tablename, and title:string is an attribute pair. For more attribute pair within the same table, just append them to the end, space delimited. Hopefully there's a menu you can do they same in Netbeans.

I hope this helps!

EDIT: Just saw a screenshot of the function in Netbeans. Under 'Model name' you can specify your table name. Under attribute pairs you can list all the columns in your table like shown above.

title:string body:text

If you are deciding to use Rails with tables that already exists, that's a more advanced topic because Rails impose a certain column names convention of it's own and it possibly means you are not going to comply with it.

Rails with Non-Rails Database Design - Stack Overflow

wai
As it happens I am using an existing database. It seems to work fine with rails, in that the scaffolding is working and I can see that all of the data is being pulled out of it just fine. I am looking for a way to avoid typing in attribute pairs for all 20 columns of the table while staying within Netbeans (I'm trying to get a good workflow going with it). Thanks for helping!
Mike Williamson