学习 rails 的第二天,一步一步来嘛!!!
rails generate model  Comment commenter:string body:text article:references  这里 comment 和 Comment 生成 Model 一样的rails db:migrate
 <%= form_for([@work, @work.comments.build]) do |f| %>
  <p>
    <%= f.label :commenter %><br>
    <%= f.text_field :commenter %>
  </p>
  <p>
    <%= f.label :body %><br>
    <%= f.text_area :body %>
  </p>
  <p>
    <%= f.submit %>
  </p>
<% end %>
再看看对应的 Controller 方法
def show
  @work=Work.find params[:id]
end
def create
 @work=Work.new work_params
 if @work.save
    redirect_to @work
else 
    render 'new'
  end
end
<%= form_for([@work, @work.comments.build]) do |f| %>   因为 create 的路由是  post  /works/:work_id/comments(.:format) 评论需要嵌套在文章中,@work 是在 controller 中查找到的对象,在@work  model 中用 has_many 关联了,所以能在@work.comments.build 可以用** 这里 render ,link_to, redirect_to ** 三者的区别
@work 就是 show 页  @work 不是在 create 方法中创建的一个对象吗?难道因为路由是 work GET /works/:id(.:format) works/show 吗   这里自己的理解也不好,百度了好多也是模模糊糊的 代码位置 app/views/articles/show.html.erb
<h2>Comments</h2>
<% @work.comments.each do |comment| %>
  <p>
    <strong>Commenter:</strong>
    <%= comment.commenter %>
  </p>
  <p>
    <strong>Comment:</strong>
    <%= comment.body %>
  </p>
<% end %>
将 Controller 中找到的@work中的 comments 模型内容显示出来,demo 在 (https://github.com/yngzij/rails-) 希望对后来的朋友有帮助