Skip to content

Adds support for missing PostgreSQL data types to ActiveRecord

Notifications You must be signed in to change notification settings

sendle/postgres_ext

This branch is 4 commits ahead of, 121 commits behind DavyJonesLocker/postgres_ext:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

cea75c0 · Oct 16, 2013
Aug 1, 2013
Oct 16, 2013
Aug 2, 2013
Sep 24, 2012
May 3, 2012
Jun 14, 2013
Jun 21, 2013
Dec 13, 2012
Aug 2, 2013
Aug 23, 2013
Sep 13, 2012
Aug 23, 2013

Repository files navigation

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

About

Adds support for missing PostgreSQL data types to ActiveRecord

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 99.1%
  • Other 0.9%