Sha256: d189068cb88a519a6a630edbae12700f48b3b1a94d7e18ed5c5e8a882dbcb648
Contents?: true
Size: 682 Bytes
Versions: 6
Compression:
Stored size: 682 Bytes
Contents
# Unpolymorph Foreign key based replacement for polymorphic associations. ## Installation Add this line to your application's Gemfile: gem 'unpolymorph' And then execute: $ bundle Or install it yourself as: $ gem install unpolymorph ## Usage class Comment < ActiveRecord::Base unpolymorph :commentable, %w{ user article post } end c = Comment.new c.commentable = User.first c.commentable # User... Comment.possible_commentable?( Post.first ) # true Comment.possible_commentable?( Group.first ) # false # in migration Comment.update_sql_commentable_check( migration ) # creates SQL check constraint ensuring exactly one of commentable foreign keys is set
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
unpolymorph-0.2.2 | README.md |
unpolymorph-0.2.1 | README.md |
unpolymorph-0.2.0 | README.md |
unpolymorph-0.1.2 | README.md |
unpolymorph-0.1.1 | README.md |
unpolymorph-0.1.0 | README.md |