0
每当我尝试并从datamapper中计数返回的记录时,它总是返回0,无论是否有用户。Ruby Datamapper .count总是返回0
User.count(:username=>params[:username])
class User
include DataMapper::Resource
property :id, Serial
property :username, String, unique_index: true, required: true, length: 3..32
property :password, String, required: true, length: 5..64
property :email, String, unique_index: true, required: true, format: :email_address
end
你100%肯定有一个在你的数据库中的用户?您可以提供更多的代码片段的上下文吗? – Makoto
@Makoto这里肯定有一个用户,因为如果我删除if语句,那么所有其他代码都会执行得很好,这涉及从数据库获取详细信息。至于更多的代码,我刚刚更新了它。 – DCWill