上传控制器
def create
@upload = @order.uploads.build(params[:uploadtwo])
respond_to do |format|
if @upload.save
format.html { redirect_to root_path, :notice => 'File was successfully uploaded.' }
format.json { render :json => @upload, :status => :created, :location => @upload }
else
format.html { render :action => "new" }
format.json { render :json => @upload.errors, :status => :unprocessable_entity }
end
结尾
上传模型
belongs_to :order
订单模型
has_many :uploads
我收到错误 [NoMethodError in UploadtwosController#create],[未定义的方法 `uploads' for nil:NilClass]
有人知道我没有做什么吗?