Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 在rails中动态添加表单(非嵌套)_Ruby_Ruby On Rails 3_Ruby On Rails 3.2 - Fatal编程技术网

Ruby 在rails中动态添加表单(非嵌套)

Ruby 在rails中动态添加表单(非嵌套),ruby,ruby-on-rails-3,ruby-on-rails-3.2,Ruby,Ruby On Rails 3,Ruby On Rails 3.2,请有人解释一下我如何在rails中动态添加表单的另一个副本?…我已经为此工作了将近2个小时。我在jquery中乱搞了.clone()和.appendTo,但它不起作用。此外,我在网上找到的大多数资料(如railscast#196和stackoverflow)都非常关注嵌套表单。我的表单是嵌套的,但实际上我只想再次添加父表单。嵌套的照片使用html多属性,因此我猜这将处理每个父表单的多个文件上载(顺便说一句,我使用的是回形针) 如果我只需要修改railscast代码,请告诉我 谢谢 <%=

请有人解释一下我如何在rails中动态添加表单的另一个副本?…我已经为此工作了将近2个小时。我在jquery中乱搞了.clone()和.appendTo,但它不起作用。此外,我在网上找到的大多数资料(如railscast#196和stackoverflow)都非常关注嵌套表单。我的表单是嵌套的,但实际上我只想再次添加父表单。嵌套的照片使用html多属性,因此我猜这将处理每个父表单的多个文件上载(顺便说一句,我使用的是回形针)

如果我只需要修改railscast代码,请告诉我

谢谢

<%= form_for(@user_book, html: { multipart: true }) do |f| %>
<% if @user_book.errors.any? %>
<div id="error_explanation">
  <h2><%= pluralize(@user_book.errors.count, "error") %> prohibited this user_book from been saved:</h2>
  <ul>
  <% @user_book.errors.full_messages.each do |msg| %>
    <li><%= msg %></li>
    <p>hello</p>
  <% end %>
  </ul>
</div>
<% end %>

<%= f.text_field :title, placeholder: "enter title...", id: "book_title" %>
<%= f.text_field :category, placeholder: "enter category..." %>
<%=  file_field_tag 'user_book[user_book_photos_attributes][][photo]', :multiple => true         do |p| %>
   <%= p.file_field :photo %> 
<% end %>

<div class="actions">
<%= f.submit %>
</div>
<% end %>

已禁止保存此用户手册:
  • 你好

真do | p |%>
因此,当用户单击“保存”时,所有表单都将提交?基本上是的……我希望用户能够一次提交多个列表。请解释正在创建的对象的模型关系好吗?签出并查看这是否是您想要的。@user\u books有许多user\u book\u照片…我也有一本书的模型在特定条件下创建…但这是在我的模型中完成的…我认为这不重要