评论表格无法呈现

时间:2011-12-31 13:41:24

标签: ruby-on-rails forms comments nested rendering

Rails 3由于某种原因无法呈现评论表单,表单为:

<% form_for ([@post.eng_post, @post.eng_post.eng_comments.build]) do |f| %>

但是

<%= debug @post.eng_post.eng_comments.build %>

给出

--- !ruby/object:EngComment
attributes:
  id: !!null 
  eng_post_id: 97
  full_name: !!null 
  website: !!null 
  email: !!null 
  comment: !!null 
  created_at: !!null 
  updated_at: !!null 

模型的结构如下:

Posts (have one)-> EngPost (has many)-> EngComments

(更详细的模型在这里Rails 3, comments in a nested form, wrong routes?

由于

1 个答案:

答案 0 :(得分:3)

<% form_for替换为<%= form_for