zhao-zhu/blog_1 — comment on commit 5662dd136a939c40a4f2e4fc5efc808532e88c9e
File:  line 0
By zhaoguobin:

1. 在```app/models/post.rb```中添加对comment的关联

```
has_many :comments
```

2.新建```comment```controller

```
rails g controller Comments
```
3.修改路由```config/routes.rb```

```
resources :posts do
resources :comments
end
```

4.在```comment```controller中添加```create```action

```
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create(params[:comment])
redirect_to post_path(@post)
end
```
5.修改```app/views/posts/show.html.erb```页面