Ruby Datamapper .count始终返回0 [英] Ruby Datamapper .count always returns 0

查看:75
本文介绍了Ruby Datamapper .count始终返回0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试计算从datamapper返回的记录时,无论是否有用户,它总是返回0。

Whenever I try and count the returned records from datamapper it always returns as 0, whether there is a user or not.

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


推荐答案

可以在控制台
中尝试 User.all(:username => params [:username])和然后为该ENV尝试

Can you try User.all(:username=>params[:username]) in console and then try

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

这篇关于Ruby Datamapper .count始终返回0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆