title: "TypeError: can't quote" when using custom types and the attributes API
body: <p>I'm running into a problem when trying to use the Attributes API to allow a custom type in my ActiveRecord models. I can get everything working until I try to access a relationship. When I do that, I receive a <code>TypeError: can't quote</code> error. This appears to be caused by <code>ActiveRecord</code> when it tries to "quote" the attribute. I'm assuming it serializes the attribute before quoting. Does anyone see something I am missing?</p>
  
  <p>Model:</p>
  
  <pre><code>class MyClass &lt; ActiveRecord::Base
     attribute :my_attr, :my_custom
     has_many :others, primary_key: :my_attr
  end
  </code></pre>
  
  <p>Attribute Type:</p>
  
  <pre><code>class MyCustomType &lt; ActiveRecord::Type::String
  
    def deserialize(value)
      MyCustom.new(value)
    end
  
    def cast(value)
      MyCustom.new(value)
    end
  
    def serialize(value)
      value.to_s
    end
  
  end
  </code></pre>