Created
March 1, 2010 05:53
-
-
Save jkongie/318112 to your computer and use it in GitHub Desktop.
Factory Girl - Polymorphic Factory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setting up a polymorphic factory for a join table | |
# Since rosterable is not the default name of the model we are calling, we can't use the convenience method | |
# that is used for area (f.association) | |
# All we have to do is fall back to the block way of doing it, calling f.rosterable and passing in the | |
# object you want to populate it with ( in this case a template). This will fill in both rosterable_id | |
# and rosterable_type for us | |
Factory.define(:template_rostered_area, :class => RosteredArea) do |f| | |
f.association :area | |
f.rosterable { |a| a.association(:template)} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍