Skip to content

Instantly share code, notes, and snippets.

View dangerousbeans's full-sized avatar

Joran Kikke dangerousbeans

View GitHub Profile
@gerred
gerred / double_polymorphism.rb
Created March 5, 2011 00:13
Doubly Polymorphic Join Models, for fun and profit
class Delivery < ActiveRecord::Base
belongs_to :deliverable, :polymorphic => true
belongs_to :receivable, :polymorphic => true
has_many :delivery_impressions
has_many :users, :through => :delivery_impressions
belongs_to :sender, :class_name => 'User', :foreign_key => :sender_id
end
class DeliveryImpression < ActiveRecord::Base