我在保存通过表单传递的数据时遇到了一些小问题...如果我试图用.save()保存记录,它不会保存..当我查看服务器/日志时,没有出现回形针gem的错误或警告:-/
# trying to save the record with save() -- not working :-/
def create
@baan_import = BaanImport.new(params[:baan_import])
if @baan_import.save
redirect_to(baan_imports_url)
else
render 'new'
end
end服务器日志:(在控制器中使用.save() ) https://gist.github.com/1327347
如果我使用.create而不是.save(),我就不明白为什么它能工作。
# trying to save the record with Model.create() -- working!
def create
@baan_import = BaanImport.create(params[:baan_import])
redirect_to(baan_imports_url)
end服务器日志:(在控制器中使用.create() ) https://gist.github.com/1327359
有人能解释一下为什么它和create一起工作而不是save吗??
谢谢,
迈克尔
发布于 2011-10-31 20:15:31
你能给我们看一下BaanImport模型吗。我的第一个猜测是,您可能在模型的attr_accessible中缺少baan_upload,因此,Rails不会让您批量分配用于上传的文件参数。
你还能确认(看起来像是正确设置的)你的表单有html => {:multipart => true}选项吗?
https://stackoverflow.com/questions/7953522
复制相似问题