title: Rails find by integer property fails
body: <p>I have this query in a GET route:</p>
  
  <pre><code>@user = User.where("facebook_id = ?", params[:id].to_i).first
  </code></pre>
  
  <p><code>facebook_id</code> is type <code>bigint</code></p>
  
  <p>and I am feeding it values that I know exist based on printing out all the properties in all my <code>User</code> models. The problem is this query only works on some numbers.</p>
  
  <p>It works for these numbers:</p>
  
  <pre><code>1095512640500310
  10155111451974992
  10100608785176432
  </code></pre>
  
  <p>but not for these numbers</p>
  
  <pre><code>10154326172258840
  10205871322198368
  10153714225855256
  </code></pre>
  
  <p>Why does this query work for some numbers but not others?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Here is a screenshot of a different query that prints out <code>facebook_id</code> values:</p>
  
  <p><a href="https://i.stack.imgur.com/9UUIF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9UUIF.png" alt="enter image description here"></a></p>
  
  <p>but this query: <code>@user = User.find_by_facebook_id(10154326172258840)</code> </p>
  
  <p>returns <code>nil</code> for <code>@user</code></p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I found that there is a discrepency between the value in the DB and the value that rails prints out. If I print out the <code>facebook_id</code> for this particular user in PG, I see this:</p>
  
  <p><a href="https://i.stack.imgur.com/IypFC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IypFC.png" alt="enter image description here"></a></p>
  
  <p>The last digit here is <code>1</code> while the last digit in the rails print out is <code>0</code>.</p>
  
  <p>Why would rails be printing out an incorrect value? Is it rounding for some reason?</p>