下午所有,在註冊時設計回滾
我正在嘗試使用載波上傳圖片進行註冊。誰能告訴我爲什麼這些參數回滾或指向正確的方向。我正在使用設計的標準註冊控制器,並沒有創建自己的。
Started POST "/users" for 127.0.0.1 at 2013-11-20 15:16:15 +0100
Processing by Devise::RegistrationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"bB/oSY5s5ohDqivn63sbbehPxQxzkVlt5WVB7BDYNsI=",
"user"=>{"first_name"=>"Shaun", "last_name"=>"Shaun",
"profile_name"=>"Shaunj9k", "email"=>"[email protected]",
"password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]",
"avatar"=>#<ActionDispatch::Http::UploadedFile:0x007f3d94a114d0
@tempfile=#<File:/tmp/RackMultipart20131120-18938-onc1k9>, @original_filename="12673_607433832654038_1101803441_n.jpg",
@content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"user[avatar]\"; filename=\"12673_607433832654038_1101803441_n.jpg\"\r\nContent-Type: image/jpeg\r\n">,
"avatar_cache"=>""},
"commit"=>"Sign up"}
(0.7ms) BEGIN
User Exists (71.8ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = '[email protected]' LIMIT 1
(0.3ms) ROLLBACK
好吧,我一直想弄明白這一點。我現在已經創建了一個自定義控制器,並將其撬在裏面。這是如下過程:
def create
build_resource(sign_up_params)
binding.pry
if resource.save
yield resource if block_given?
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_flashing_format?
sign_up(resource_name, resource)
respond_with resource, :location => after_sign_up_path_for(resource)
else
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
expire_data_after_sign_in!
respond_with resource, :location => after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
respond_with resource
end
end
所以,當我得到這個斷點和檢查參數,可以這是所示,它跳躍的權利之前,其他:
[2] pry(#<RegistrationsController>)> sign_up_params
=> {"first_name"=>"Marlene",
"last_name"=>"Annoying",
"profile_name"=>"AnnoyingMarlene",
"email"=>"[email protected]",
"password"=>"admin1234",
"password_confirmation"=>"admin1234",
"avatar"=>
#<ActionDispatch::Http::UploadedFile:0xb2f69d18
@content_type="image/jpeg",
@headers=
"Content-Disposition: form-data; name=\"user[avatar]\"; filename=\"picture.jpeg\"\r\nContent-Type: image/jpeg\r\n",
@original_filename="picture.jpeg",
@tempfile=#<File:/tmp/RackMultipart20131121-14703-1fubdpu>>,
"avatar_cache"=>"1385025876-14703-8014/Link_to_sublime_text"}
這裏是商店目錄在AvatarUploader.rb
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
你能在'create'行爲的'@ user.errors.full_messages'數組中找到什麼? – marzapower
我正在使用設計的註冊控制器,所以我會如何顯示。 –
Uhm,一個快速的方法:嘗試使用'User.create!({...})'在'pry'中使用相同的參數。然後尋找錯誤 – marzapower