为什么在rails 4中使用carrierwave上传文件时我得到’回滚交易’?

我不确定为什么我得到以下错误。 我是铁杆的新手,任何帮助和建议将不胜感激。

  1. 我正在创建一个招聘网站
  2. 我试图让求职者上传他们成功运作的个人资料图片
  3. 现在,我试图让求职者上传他们的简历
  4. 当我尝试上传简历并保存时,我得到以下错误
  5. 我已经按照了载波的步骤,但我似乎仍然无法看到我出错的地方
  6. 当我尝试上传pdf文件或doc文件时,错误提示,上传jpg文件工作正常

任何帮助或建议将不胜感激。

终端中的错误信息:

回滚事务

Started PATCH "/userjs/1" for 127.0.0.1 at 2015-06-21 20:33:44 +0100 Processing by UserjsController#update as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"KosfL1GqfZM03PFWb2aMuIKKlgPcMLSkITI9VIbjKcA=", "userj"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x007fb75c2d5f58 @tempfile=#, @original_filename="profileimage.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"userj[image]\"; filename=\"profileimage.jpg\"\r\nContent-Type: image/jpeg\r\n">, "cvattachment"=>#<ActionDispatch::Http::UploadedFile:0x007fb75c2d5e90 @tempfile=#, @original_filename="00. Resume - A. Richill Tamakloe.pdf", @content_type="application/pdf", @headers="Content-Disposition: form-data; name=\"userj[cvattachment]\"; filename=\"00. Resume - A. Richill Tamakloe.pdf\"\r\nContent-Type: application/pdf\r\n">, "firstname"=>"aknorbea", "lastname"=>"artloe", "city"=>"accra", "language"=>"french | gary carr"}, "commit"=>"Update Userj", "id"=>"1"} Userj Load (0.1ms) SELECT "userjs".* FROM "userjs" WHERE "userjs"."id" = ? LIMIT 1 [["id", 1]] (0.1ms) begin transaction (0.1ms) rollback transaction Rendered userjs/_form.html.erb (10.3ms) Rendered userjs/edit.html.erb within layouts/application (11.5ms) Completed 200 OK in 554ms (Views: 539.4ms | ActiveRecord: 0.2ms) 

上传/ cvattachment.rb

 # encoding: utf-8 class CvattachmentUploader < CarrierWave::Uploader::Base storage :file def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end def extension_white_list %w(jpg jpeg gif png) end end 

schema.rb

 ActiveRecord::Schema.define(version: 20150621190355) do create_table "userjs", force: true do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.datetime "created_at" t.datetime "updated_at" t.string "firstname" t.string "lastname" t.integer "number" t.string "city" t.string "image" t.string "cvattachment" end add_index "userjs", ["email"], name: "index_userjs_on_email", unique: true add_index "userjs", ["reset_password_token"], name: "index_userjs_on_reset_password_token", unique: true end 

userj.rb

 class Userj < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable has_many :adverts, through: :forms has_many :forms mount_uploader :image, ImageUploader mount_uploader :cvattachment, CvattachmentUploader end 

视图/ userjs / _form.html.erb

   
image cv

视图/ userjs / show.html.erb

 

profile image:

cv:

|

CvattachmentUploader注释这些行

 def extension_white_list %w(jpg jpeg gif png) end 

重启服务器,然后重试。