Creating new project:
rails new blog bundle install
rails g model Post title:string body:text rails g model Comment name:string body:text post:references
Then in post.rb add:
has_many :comments, dependent: :destroy
dependent: :destroy, removes all comments related to a post when you delete it.
Notice that in comment.rb, you have this line:
... belongs_to :post ...
Some paths for the templates (views):
root_path new_post_path edit_post_path post_path
render, just includes the file (html.erb), while redirect_to opens the page:
render 'new' redirect_to @post
To cancel the last migration:
rake db:rollback STEP=1