我有一个模型submission
和一个嵌套模型attachment
在submission.rb
:
has_many :assets, :dependent => :destroy
accepts_nested_attributes_for :assets, :allow_destroy => true
在assets.rb
:
attr_accessible :file_id, :attachment
belongs_to :submission
has_attached_file :attachment
在我的submission
控制器中:
def new
@submission = Submission.new
@asset = 2.times{ @submission.assets.build }
respond_to do |format|
format.html # new.html.erb
format.json { render json: @submission }
end
end
def edit
@submission = Submission.find(params[:id])
@asset = 2.times{ @submission.assets.build }
end
我遇到了一个unknown attribute: submission_id
错误。
这里可能有什么问题。
我在这里关注截屏视频: http ://www.emersonlackey.com/article/rails-paperclip-multiple-file-uploads