Note that there are some explanatory texts on larger screens.

plurals
  1. PORuby Datamapper count not working
    text
    copied!<p>From irb when I do:</p> <pre><code>Router.all(:email=&gt;"blake@gmail.com") </code></pre> <p>I get a list of all the routers associated with that email. But when I do:</p> <pre><code>Router.count(:email=&gt;"blake@gmail.com") </code></pre> <p>I always get 0 </p> <p>I've also looked at this question: <a href="https://stackoverflow.com/questions/12548032/ruby-datamapper-count-always-returns-0">Ruby Datamapper .count always returns 0</a> but I still don't know why it isn't working.</p> <p>-- Update #1 -- </p> <p>Here is the output of the Router.all command. As you can see I get results back.</p> <pre><code>1.9.3-p362 :003 &gt; Router.all(:email=&gt;"blake@gmail.com") =&gt; [#&lt;Router @id=8 @email="blake@gmail.com" @hostname="router0"&gt;, #&lt;Router @id=9 @email="blake@gmail.com" @hostname="router0"&gt;, #&lt;Router @id=10 @email="blake@gmail.com" @hostname="router0"&gt;, #&lt;Router @id=11 @email="blake@gmail.com" @hostname="router0"&gt;, #&lt;Router @id=13 @email="blake@gmail.com" @hostname="router0"&gt;, #&lt;Router @id=14 @email="blake@gmail.com" @hostname="router0"&gt;, #&lt;Router @id=15 @email="blake@gmail.com" @hostname="router0"&gt;, #&lt;Router @id=16 @email="blake@gmail.com" @hostname="router0"&gt;] </code></pre> <p>But when I do Router.count as suggested it still is returning 0</p> <pre><code>1.9.3-p362 :004 &gt; Router.count(:conditions =&gt; ["email = ?", "blake@gmail.com"]) =&gt; 0 1.9.3-p362 :005 &gt; Router.count(:conditions =&gt; "email = 'blake@gmail.com'") =&gt; 0 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload