Created
February 20, 2010 17:04
-
-
Save ilpoldo/309773 to your computer and use it in GitHub Desktop.
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
class Album < ActiveRecord::Base | |
has_one :feature, :as => :featured | |
end |
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
Factory.define :album do |a| | |
a.author "A boring author name" | |
a.title "A boring title" | |
a.tracks {rand(20)} | |
end | |
Factory.define :feature do |f| | |
f.title 'A Dull Album' | |
f.description 'Read on for more info' | |
f.text 'blah blah blah' | |
f.featured {Factory :album} | |
end | |
# Is there a way to deal with factories like this using pickle? | |
Factory :feature, :title => 'Foo\'s out with a new album', | |
:description => 'Are they raising the bar?', | |
:featured => Factory(:album, :author => 'Foo and the Bars') |
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
class Feature < ActiveRecord::Base | |
belongs_to :featured, :polymorphic => true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment