Carrierwave:在嵌套表单中传递User_ID

时间:2011-12-20 09:14:53

标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-3.1 carrierwave

在将user_id保存到数据库表Documents时遇到问题。现在,当我在POST中检查rails服务器登录时,它没有发送任何与user_id相关的文件。

projects_controller.rb

def new_step_3
  project = Project.new
  @project.documents.build
end

new_step_3.html.erb

<%= form_for @project, :html => {:multipart => true} do |f| %>
  <%= f.text_field :title %>
  <%= f.text_field :description %>

  <%= f.fields_for :documents do |builder| %>
    <%= builder.file_field :title %>
  <% end %>

  <%= f.text_field :skills %>
  <%= f.submit 'Post Project' %>
<% end %>

1 个答案:

答案 0 :(得分:0)

您是否在项目模型中包含了行accepts_nested_attributes_for :documents