开发者

rails 3 form_for doesn't output anything

开发者 https://www.devze.com 2023-01-26 18:18 出处:网络
Hi I have any form with nested form, for example <% form_for :main do |f| %> trying to insert code here

Hi I have any form with nested form, for example

<% form_for :main do |f| %>
  trying to insert code here
 开发者_如何学Python <% fields_for :nested do |nested_form| %>
    <%= nested_form.text_field :description %>
  <% end %>
<% end %>

And then I am trying to insert anything to a main form, nested form doesn't produce any output. It outputs only when it is the only object in main form. Any suggestions?


From the Rails 3 documentation examples you need to write your form_for like this:

<%= form_for :main do |f| %>
  # trying to insert code here
   <%= fields_for :nested do |nested_form| %>
    <%= nested_form.text_field :description %>
  <% end %>
<% end %>

Note the <%= for both form_for and fields_for

0

精彩评论

暂无评论...
验证码 换一张
取 消