【问题标题】:Comments form can't be rendered无法呈现评论表单
【发布时间】:2011-12-31 13:41:24
【问题描述】:

Rails 3 由于某种原因无法渲染 cmets 表单,表单为:

<% 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?

谢谢

【问题讨论】:

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


    【解决方案1】:

    &lt;% form_for 替换为&lt;%= form_for

    【讨论】:

    • 谢谢!!!我实际上是从 Rails 2 迁移过来的。像这样的小东西太多了! :)
    猜你喜欢
    • 1970-01-01
    • 2020-06-26
    • 2012-08-31
    • 2016-04-20
    • 2019-08-15
    • 2013-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多