RadRails and Scaffold-Migration Best Practice

So, started tinkering again with Ruby on Rails tonight. It's been about a year since I last worked with RoR, so I wanted to familiarize myself with it again.

Fired up RadRails. Let me say that this has undergone vast improvement since I used it a year ago, and I would feel totally comfortable recommending it to anyone. I have been able to manage the entire development process from within the IDE: create and empty application, generate models, views, controllers, and migrations; instantiate, start and stopp servers; rake tasks, database management...so far, I can do everything through the IDE. I'm very impressed.

Then, I spent an hour or so screwing around with a little test app to re-familiarize myself with how the whole thing worked. An issue here and there, but generally speaking it all worked out well.

I'm still trying to get my head around the whole script/generate scaffold thing in relation to migrations. You have to setup the DB table before you can run script/generate scaffold. But, you have to run script/generate model to setup the migration and then run rake db:migrate. This seems feels like I'm doing something wrong because I thought script/generate scaffold is supposed to setup the model too. That's how it was a year ago, in pre-migration days. I have to figure out the best practice now...suggestions are welcome in the comments.

1 comment:

Mark Puckett said...

I think the best practice is to 1) create your model (and thus migration), 2) run the migration, 3) create your controllers/views however you choose (in your case you're using scaffolding).