评论表格无法呈现

时间:2022-11-23 17:14:00

Rails 3 can't render the comments form for some reason, the form is:

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

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

but

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

gives

--- !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 

The models are structured as:

模型的结构如下:

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

(More detailed models are here Rails 3, comments in a nested form, wrong routes?)

(更详细的模型在这里是Rails 3,嵌套形式的注释,错误的路由?)

Thanks

1 个解决方案

#1


3  

Replace <% form_for with <%= form_for

将<%form_for替换为<%= form_for

#1


3  

Replace <% form_for with <%= form_for

将<%form_for替换为<%= form_for