

Rails 4.0 Sneak Peek: Expanded ActiveRecord Support for PostgreSQL Datatypes - phsr
http://reefpoints.dockyard.com/ruby/2012/05/18/rails-4-sneak-peek-expanded-activerecord-support-for-postgresql-datatype.html

======
emmett
I want support not just for PostgreSQL native datatypes, I want ActiveRecord
support for adding my own custom datatypes.

~~~
jeremymcanally
You can pretty much do that right now (and have been able to for years) with
composed_of:
[http://api.rubyonrails.org/classes/ActiveRecord/Aggregations...](http://api.rubyonrails.org/classes/ActiveRecord/Aggregations/ClassMethods.html)
(search on that page for it)

~~~
joevandyk
The problem is that custom pg types are represented as strings in ActiveRecord
< 4.0.

In AR 4.0, you can have ActiveRecord automatically cast them to a different
type.

~~~
bcardarella
Type casting is fine but if you need to use schema.rb you'll have to use the
sql alternative. Adding explicit support for the existing datatypes allows,
amongst other things, the schema.rb

~~~
lobster_johnson
We had to abandon schema.rb early because we use PostGIS, functional indexes,
partial indexes and foreign key constraints, none of which are supported. (FKs
may be supported now, but at the time we had to monkeypatch AR to support it,
before eventually abandoning schema.rb altogether.)

Schema.rb is inherently a broken concept anyway, because it's lossy. What you
really want is the SQL, which is the only format that completely encapsulates
your schema in AR. I often wish AR was declarative for that reason.

The default Rails tooling for loading and dumping the structure is also
completely harebrained (google it and you will get a gazillion hits), so we
wrote our own internal gem that does all of it for us, along with overriding
db:test:prepare.

------
dmishe
You can say what you want about rails, but i really admire the pace they make
progress.

------
tferris
Rails is the new Java.

