ruby-on-railsactiverecordearthdistance

Custom Database Type in ActiveRecord


I am using Rails 3.1.1 with PostgreSQL 9.1 and the earthdistance module. To be able to calculate the distance between different locations properly, I have setup a column with the earth type in my branches table.

The problem I am experiencing now is that my Rails application that uses this table does not understand the earth type and thus I am getting this in my db/schema.rb:

# Could not dump table "branches" because of following StandardError
#   Unknown type 'earth' for column 'location'

This is problematic since now I can't create my test database from the schema.rb.

How can I add this type to AR or make it ignore that column?


Solution

  • Try this:

    Change you config/application.rb

    config.active_record.schema_format = :sql
    

    This will change the output format to the native PostgreSQL SQL format, schema.rb will be disabled and a new file will be generated /db/config/structure.sql