Ruby Datamapper .count始终返回0

时间:2012-09-22 22:00:30

标签: ruby postgresql datamapper

每当我尝试从datamapper计算返回的记录时,它总是返回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

1 个答案:

答案 0 :(得分:0)

您可以在控制台中尝试User.all(:username=>params[:username])吗? 然后尝试

那个ENV的

User.count(:username=>params[:username])