I'm trying to get started with Rails, but I'm running into a few places where I'm having trouble understanding the expected workflow. I'm trying to work with migrations from the beginner; its a port of an existing application, but I'd like to let the db schema evolve as the application grows, so I'm starting from an empty (tableless) database. If I generate a migration, I can fill in the up/down methods and start creating a table; rake migrate ran fan. However when I then generate a model it seems to create another migration automatically that is named appropriately for the eariler self-created migration. This seemed odd, so I thought I did something against the expected way. As I hadn't done anything, I wiped the DB and the rails project and recreated both. This time I tried generating a scaffolding first, thinking that it would create the first migration that I would then fill in and get things rolling from there. This generated the "before updating scaffolding from a new DB schema..." error. (Which makes sense to me now that I think about it.) Can anyone help me out and explain what the "expected" order of "generate foos" are when starting from a completely blank slate if I want to do things the "rails"-way? (I would prefer to use migrations as opposed to creating the ddl manually, as long as that preference isn't at odds with normal rails practices) Also, am I correct that the only way to "back-out" a script/generate foo is to rollback via version control? Thank you.
on 2006-05-22 08:11
on 2006-05-22 08:44
On Monday, May 22, 2006, at 6:11 AM, Eric N. wrote: >appropriately for the eariler self-created migration. This seemed odd, >want to do things the "rails"-way? (I would prefer to use migrations as >_______________________________________________ >Rails mailing list >email@example.com >http://lists.rubyonrails.org/mailman/listinfo/rails There are a few things about the generators that are a bit odd. Here's the process I use. 1. generate the model. this generates a migration file, which I then fill out with the appropriate fields and foreign keys. 2. rake migrate 3. generate the scaffold, ignore/delete any migration files it may create. 4. lather, rinse, repeat. You can undo a 'script/generate foo' with a 'script/destroy foo'. _Kevin