Ruby Datamapper .count always returns 0

Deadly 提交于 2019-12-12 05:39:34

问题


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

回答1:


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

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



来源:https://stackoverflow.com/questions/12548032/ruby-datamapper-count-always-returns-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!