Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Adds support for missing PostgreSQL data types to ActiveRecord

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 docs
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rspec Test inet data type migrations May 03, 2012
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 CHANGELOG.md
Octocat-spinner-32 CONTRIBUTING.md Update CONTRIBUTING.md December 13, 2012
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 postgres_ext.gemspec
README.md

PostgresExt

Adds support for missing PostgreSQL data types to ActiveRecord.

Build Status Code Climate

Looking for help?

If it is a bug please open an issue on Github. If you need help using the gem please ask the question on Stack Overflow. Be sure to tag the question with DockYard so we can find it.

Installation

Add this line to your application's Gemfile:

gem 'postgres_ext'

And then execute:

$ bundle

Or install it yourself as:

$ gem install postgres_ext

Usage

Just require 'postgres_ext' and use ActiveRecord as you normally would! postgres_ext extends ActiveRecord's data type handling.

Usage Notes

Avoid the use of in place operators (ie Array#<<). These changes are not tracked by Rails (this issue) explains why). In place modifications also modify the default object.

Assuming we have the following model:

create_table :items do |t|
  t.string :names, :array => true, :default => []
end

class Item < ActiveRecord::Base
end

The following will modify the default value of the names attribute.

a = Item.new
a.names << 'foo'

b = Item.new
puts b.names
# => ['foo']

The supported way of modifying a.names:

a = Item.new
a.names += ['foo']

b = Item.new
puts b.names
# => []

As a result, in place operators are discouraged and will not be supported in postgres_ext at this time.

Authors

Dan McClain twitter github

Something went wrong with that request. Please try again.