Ruby on rails 接受\u嵌套的\u属性\u,具有\u多个多态性
我用回形针上传多个附在学生课程签名上的文件,但我失败了 型号Ruby on rails 接受\u嵌套的\u属性\u,具有\u多个多态性,ruby-on-rails,ruby,ruby-on-rails-3.2,Ruby On Rails,Ruby,Ruby On Rails 3.2,我用回形针上传多个附在学生课程签名上的文件,但我失败了 型号 class StudentCourseAssignment < ActiveRecord::Base attr_accessible :score, :comment, :finish_status,:attachments accepts_nested_attributes_for :attachments belongs_to :assignment belongs_to :user
class StudentCourseAssignment < ActiveRecord::Base
attr_accessible :score, :comment, :finish_status,:attachments
accepts_nested_attributes_for :attachments
belongs_to :assignment
belongs_to :user
has_many :attachments ,:as => :attachmentable,:dependent => :destroy
end
class Attachment < ActiveRecord::Base
attr_accessible :user_upload
belongs_to :attachmentable , :polymorphic => true
has_attached_file :user_upload
end
**看法**
<%= form_for @sca, :url => assignment_student_course_assignments_path(@assignment),
:html => { :id => 'student-assignment-form', :multipart => true } do |f| %>
file:
<%= f.fields_for :attachments do |a_f| %>
<%= a_f.file_field :user_upload %>
<%= submit_tag "create" %>
<% end%>
<% end %>
如果remove为:附件接受\u嵌套的\u属性,\u,它仍然是错误的
Attachment(#70201401779680) expected, got Array(#70201383294620)
希望您的帮助!谢谢强>变化
发件人:
致:
我知道这是一个老问题,但我想你需要离开
接受:附件的\u嵌套\u属性\u
侍候
有很多附件,:as=>:attachmentable,:dependent=>:destroy
我自己曾经在一个项目中遇到过这个问题;可以肯定的是,接受
的_嵌套的_属性_,希望在调用关系之前已经声明了关系
No association found for name `attachments'. Has it been defined yet?
Attachment(#70201401779680) expected, got Array(#70201383294620)
attr_accessible :score, :comment, :finish_status,:attachments
attr_accessible :score, :comment, :finish_status,:attachments_attributes