The workflow we will follow looks like this:
- Planning
- Initializing Application
- Building the Rails Model
- Configure our Dev Environment
- Defining Routes
- Writing Controllers and their Views (iterate)
- Styling Views
- Share!
####Part one
Planning:
- user stories
- role, goal, reason
- itemize features
- define MVP (minimally-vaible-project)
- create milestones
- model data (draw ERD)
- describe states (state diagram)
- index, new, create, show
- new -> CREATE (create) -> …
- READ (index), READ (show)
- edit, update, destroy
- edit -> UPDATE (update) -> …
- … -> DESTROY (destroy)
- index, new, create, show
- (wireframe -- not necessary here...)
####Part two
Initialize Application
rails new appname --database=postgresql
cd
into appname, and thengit init
git add
/git commit
Building the Rails Model
- create database (psql)
- configure database.yml
- define migration (
rails generate migration
)- column type string vs column type text et al
t.timestamps
!
- run migration
- write model(s)
- table is plural and snake_case; model class and file are both singular (in Camel and snake_ cases, respectively)
git commit
!
Configure our Development Environment
At this point we want to make sure things are working, so let's test our model and database!
- add what we want to our Gemfile ('pry-rails', 'better-errors', 'annotate', eg, all in group: development)
rails console
(orrails c
)- add some seed data…
- appname/db/seeds.rb
rake db:seed
git commit
!
####Part three
Define Routes
- organize resources from model
- non-resource-based routes (index)
git commit
!
Write Controllers and their Views
- add a controller and method
- add the requisite view
git commit
!- repeat!
- often, a good order to write controller actions is:
- Index (Displays all entries)
- New (Displays a form to create a new entry)
- Create (Creates a new entry and saves it to the database)
- Show (Displays one particular entry)
- continue:
- Edit (Displays a form to edit an existing entry)
<form action="/resource" method="post"><input type="hidden" name="_method" value="put" />
- Mimics "PUT"
- Update (Updates an entry and saves it to the database)
- Destroy (Deletes an entry)
<form action="/resource" method="post"><input type="hidden" name="_method" value="delete" />
- Mimics "DELETE"
- Edit (Displays a form to edit an existing entry)
###Part four
Style
- master stylesheet
Share!
- upload to GH
- upload to Heroku