Last active
December 22, 2015 22:39
-
-
Save kulte/6540998 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
factory :user do | |
email "[email protected]" | |
password "secret" | |
trait :with_comments do | |
after(:create) do |user, evaluator| | |
# FactoryGirl.create_list(factory, number_of_items, factory_attrs) | |
FactoryGirl.create_list(:comment, 1, user: user) | |
end | |
end | |
end | |
factory :comment do | |
text "This is a comment." | |
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
class User < ActiveRecord::Base | |
has_many :comments | |
end | |
class Comment < ActiveRecord::Base | |
belongs_to :user | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment