This gem adds PostgreSQL user defined types support for Active Record (Ruby on Rails).
Add this line to your application's Gemfile:
gem 'active_type'
And then execute:
$ bundle
Or install it yourself as:
$ gem install active_type
-
Create a new class in PostgreSQL:
CREATE TYPE your_type AS (property1 varchar, property2 datetime, property3 text);
-
Specify new column in your model table:
add_column :model_table_name, :your_type_name, :your_type
-
Specify in your model
serialize :your_type_name, YourTypeClass
Gem also supports arays and one level nested types.
Limitations:
- Doesnt support commas in arrays
- Doesnt support multiple level nested types
- Maybe doesnt support bytea type
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request