class document < ActiveRecord::Base belongs_to :company valIDates :name,:presence => trueend
并且继承自document的两个类:
执照:
class license < document mount_uploader :file,documentUploaderend
和证书
class Certificate < document mount_uploader :file,documentUploaderend
当我尝试对证书执行current_company.licenses.create(…)或相同的 *** 作时,除了文件之外总是保存所有参数,总是为零
我也尝试在document模型中挂载文件…请帮帮我.
这是日志:
Started POST "/companIEs/1/verifIEd" for 127.0.0.1 at Mon Mar 19 09:33:41 +0200 2012Processing by CompanIEsController#verifIEd as HTML Parameters: {"verifIEd"=>{"certificate"=>{"name"=>"Certificate","file"=>"test.png"},"insured"=>"2000000","suppliers"=>"","license"=>{"name"=>"license","file"=>"test.png"}},"authenticity_token"=>"0hIn41Tjonm/AXZBKM1PE/tjQxJDLqZaojMTHDoZq2k=","ID"=>"1","utf8"=>"✓","commit"=>"Update verifications"} Company Load (0.7ms) SELECT "companIEs".* FROM "companIEs" WHERE "companIEs"."ID" = 1 liMIT 1 (0.1ms) BEGIN sql (0.8ms) INSERT INTO "documents" ("company_ID","created_at","file","name","type","updated_at","verifIEd") VALUES (,,,,,,) RETURNING "ID" [["company_ID",1],["created_at",Mon,19 Mar 2012 07:33:41 UTC +00:00],["file",nil],["name","license"],["type",["updated_at",["verifIEd",false]] (0.6ms) COMMIT (0.1ms) BEGIN sql (0.5ms) INSERT INTO "documents" ("company_ID","Certificate"],false]] (0.4ms) COMMITRedirected to http://localhost:3000/company/profileCompleted 302 Found in 18ms (ActiveRecord: 3.3ms)
谢谢.
解决方法 您确定已将用于上传文件的表单设置为具有多部分有效负载吗?如果不是,文件将不会在提交时发送,并且rails将仅接收文本表单数据.在form_helper标记内,您需要添加.
:HTML => {:multipart => true}总结
以上是内存溢出为你收集整理的ruby-on-rails – CarrierWave.无法使用STI保存文件全部内容,希望文章能够帮你解决ruby-on-rails – CarrierWave.无法使用STI保存文件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)