Consistently handle casting to integer columns

This commit includes the following changes:

1) It explicitly tries to_i and then id when casting to an integer
   column, finally setting nil if none of them are available.

   This allows ActiveRecord objects to Just Work, and removes the need
   to hard code exceptional cases that should be turned to nil.

2) I have created explicit test cases that expose the original issue
   with calling new on a scope that uses an Array. As this is a common
   situation, an explicit test case is the best way to prevent
   regressions in the future.

3) Updated and separated existing tests to be explicit about the
   situation that is being tested (eg. AR objects vs. other objects
   vs. non-integers)