Skip to content

Instantly share code, notes, and snippets.

@RafeHatfield
Forked from traviskroberts/gist:2830535
Created September 19, 2013 18:06
Show Gist options
  • Save RafeHatfield/6627486 to your computer and use it in GitHub Desktop.
Save RafeHatfield/6627486 to your computer and use it in GitHub Desktop.
class Alert < ActiveRecord::Base
belongs_to :alertable, :polymorphic => true
end
class Region < ActiveRecord::Base
has_many :alerts, :as => :alertable
end
FactoryGirl.define do
Factory.define :alert do |alert|
alert.alertable { |a| a.association(:region) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment