- Discuss the domain (with others or yourself).
- Write down the user stories (features that you plan to support).
- Develop an understand of how each noun (model/table) will relate to each other.
- Draw the schema. Don't name any join tables as the combination of two other tables, find a unique noun.
- Double check your schema for any columns that don't follow convention (e.g. foreign keys should end in
_id
). - Ensure you've chosen the most appropriate type (integer, string, boolean, etc) for each column.
- Create the migrations for each table.
- Check that everything that matches your schema design.
- Migrate (note, you don't need any models defined to migrate!)
- Create the ActiveRecord models.
- Verify your models are in good shape by saving an instance of each to the database. (via
rake console
).
- Add one or two associations to your models at a time. Don't do them all at once.
- As you add each association, update your
seeds.rb
to make use of the association. Be sure to use the bang versions (create!
andsave!
) so any errors are printed when you runrake db:seed
. Considerseeds.rb
your scratch pad as you develop & test your associations. - Review your
seeds.rb
and make sure you aren't manually setting any_id
attributes. Set the association instead (president
instead ofpresident_id
). Also, don't "guess" any values for an foreign key. If you need a randomUser
, pick a random one withUser.all.sample
. - Jump back and forth between dropping, migrating, seeding and the console to verify everything. Keep a checklist so you can be sure you've tested & verified each association is working like you expect.
- By now your
seeds.rb
might be a bit messy since you used it as a scratch pad. Reviewseeds.rb
and make sure you've got a decent set of data to test you application once you start creating the web interface. Now might be a good time to review your user stories/features.
Now it's time to create the routes & views for your app. Start with the easiest to the most difficult. Be sure to follow the RESTful routing conventions. Nearly every URL should include the plural form of the model (/comments/...
).
Routes & views that display data (index & show) are going to be very helpful for testing that your app is working, so be sure you get those working first -- and working well.
Repeat the following for each model you plan on exposing CRUD functionality for (only create the routes & view for the CRUD actions you need!):
- Create a new controller file (
app/controllers/plural_model_name.rb
) - Create a view folder (
app/views/plural_model_name
) - Create the
index
route & view - Create the
show
route & view - Create the
new
route & view + thecreate
route - Create the
edit
route & view + theupdate
route - Create the
delete
route.