Datamapper 未将记录保存到 MySQL

Datamapper not saving records to MySQL

Datamapper 没有保存我的用户模型。 (这是一个 Sinatra webapp,数据库是一个 AWS RDS 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 must be between 6 and 50 characters long' 错误(使用 28(或 30?)字符密码)

max pleaner 帮我回答了这个问题。

寻求答案的 Google 员工:
检查您的验证,并确保加密不会使密码超过您的最大值。