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
DCWill
  • 3
  • 2
  • Are you 100% sure that there's a user in your database? Is there more context to your code snippet that you can provide? – Makoto Sep 23 '12 at 02:06
  • @Makoto There is definitely a user there, because if I remove the if statement then all the other code is executed fine which involves getting details from the database. As for more code, I've just updated it with that. – DCWill Sep 23 '12 at 10:45

1 Answers1

0

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

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

Manish
  • 111
  • 4