0
Datamapper未保存我的用戶模型。 (這是一個西納特拉Web應用程序和數據庫是AWS RDS的MySQL數據庫。)Datamapper未將記錄保存到MySQL
用戶模型:
class User
include DataMapper::Resource
property :uid, Serial
property :user, String, :key => true, :length => 3..20
property :pass, String, :required => true, :length => 6..50
end
的代碼來設置它:
post "/register" do
username = params["username"]
password = params["password"]
begin
encrypted_password = BCrypt::Password.create password
meme = User.new :user => username, :pass => encrypted_password
meme.save
raise DatabaseError, "User record not saved" unless meme.saved?
flash[:register] = "Welcome, new user! Please log in now."
redirect "/login"
# disabled rescue stuff...
end
end
(如果你想,自己在dittoslash.uk測試)
(我能做到這一點的堆棧溢出?如果你不能編輯了這一點)
編輯:更新驗證規則。現在我收到'Pass必須介於6到50個字符之間'的錯誤(帶有28(或30?)個字符的密碼)
如果meme沒有保存,您已經設置了數據庫錯誤。檢查記錄上的驗證錯誤。並且請在您的問題中發佈原文錯誤。 –
我無法發佈原始錯誤,因爲這通常會引發錯誤。 – Dittoslash
'通過長度不得超過50個字符' .e。 – Dittoslash