Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Composite Primary Keys support for Active Record
Ruby JavaScript

This branch is 1 commit ahead, 305 commits behind composite-primary-keys:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
scripts
tasks
test
website
.gitignore
History.rdoc
README.rdoc
README_DB2.rdoc
Rakefile
composite_primary_keys.gemspec
init.rb
install.rb
loader.rb

README.rdoc

Composite Primary Keys for ActiveRecords

Summary

ActiveRecords/Rails famously doesn't support composite primary keys. This RubyGem extends the activerecord gem to provide CPK support.

Installation

gem install composite_primary_keys

Usage

require 'composite_primary_keys'
class ProductVariation
  self.primary_keys = :product_id, :variation_seq
end
pv = ProductVariation.find(345, 12)

Factories

class ModelWithCompositeKeys < ActiveRecord::Base
  set_primary_keys :id, :updated_at
end
FactoryGirl.define do
  factory :model_with_composite_keys do
    sequence( :id ) { |n| [n,Time.now] }
    name "Brett"
  end
end

It even supports composite foreign keys for associations.

See compositekeys.rubyforge.org for more.

Running Tests

See test/README_tests.rdoc

Url

compositekeys.rubyforge.org

Questions, Discussion and Contributions

groups.google.com/group/compositekeys

Author

Written by Dr Nic Williams, drnicwilliams@gmail. Contributions by many!

Something went wrong with that request. Please try again.