title: Activerecord can't find model by attribute, even though the query is correct
body: <p>I have a Model called <code>Invitation</code> which has an attribute called <code>code</code>. The application's goal is to find the correct invitation with a code that is entered somewhere.</p>
  
  <p>My problem is, however, that even though the input is correct, ActiveRecord can't seem to find any results while querying in the database. I've created this small test to illustrate the problem:</p>
  
  <pre><code>ruby-1.9.2-p290 :003 &gt; code = Invitation.first.code
  Invitation Load (0.4ms)  SELECT "invitations".* FROM "invitations" LIMIT 1
  =&gt; "86f50776bf" 
  </code></pre>
  
  <p>So at this point I've loaded this invitation's code in a variable</p>
  
  <pre><code>ruby-1.9.2-p290 :004 &gt; i = Invitation.where(:code =&gt; code)
  Invitation Load (0.2ms)  SELECT "invitations".* FROM "invitations" WHERE "invitations"."code" = '86f50776bf'
  =&gt; [] 
  </code></pre>
  
  <p>And the response of the query is an empty array, even though the code comes straight from the database. When using <code>code == Invitation.first.code</code> to see if the values are equal, it returns <code>true</code>. I already checked both the Ruby and database's data types, they're all Strings.</p>
  
  <p>What can cause this? and how can I fix this?</p>