Q:

"TypeError: can't quote" when using custom types and the attributes API

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 TypeError: can't quote error. This appears to be caused by ActiveRecord when it tries to "quote" the attribute. I'm assuming it serializes the attribute before quoting. Does anyone see something I am missing?
Model:
class MyClass < ActiveRecord::Base
   attribute :my_attr, :my_custom
   has_many :others, primary_key: :my_attr
end

Attribute Type:
class MyCustomType < 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

A:

Tom, Add the custom type to the attribute on the corresponding class. This will tell rails how to handle that attribute on the two different classes when dealing with relationships.
class Other < ActiveRecord::Base
   attribute :my_attr, :my_custom
   belongs_to :my_class, primary_key: :my_attr
end

