Created
October 28, 2013 18:14
-
-
Save anonymous/7201764 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
[1] pry(main)> f = FactoryGirl.build(:tournament, :with_teams, teams: 20) | |
(0.3ms) BEGIN | |
User Exists (0.9ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = '[email protected]' LIMIT 1 | |
User Exists (0.5ms) SELECT 1 AS one FROM "users" WHERE "users"."username" = 'example1' LIMIT 1 | |
SQL (4.2ms) INSERT INTO "users" ("created_at", "email", "encrypted_password", "first_name", "last_name", "updated_at", "username") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id" [["created_at", Mon, 28 Oct 2013 18:06:58 UTC +00:00], ["email", "[email protected]"], ["encrypted_password", "$2a$04$pQOTHk9MXOUE8ayPjkFzmOg/ZW5j0VjyEPmz0PbTgJJc0qGs5A7Ii"], ["first_name", "Maggie"], ["last_name", "Gerlach"], ["updated_at", Mon, 28 Oct 2013 18:06:58 UTC +00:00], ["username", "example1"]] | |
PgSearch::Document Load (0.9ms) SELECT "pg_search_documents".* FROM "pg_search_documents" WHERE "pg_search_documents"."searchable_id" = $1 AND "pg_search_documents"."searchable_type" = $2 ORDER BY "pg_search_documents"."id" ASC LIMIT 1 [["searchable_id", 1], ["searchable_type", "User"]] | |
User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]] | |
SQL (0.8ms) INSERT INTO "pg_search_documents" ("content", "created_at", "searchable_id", "searchable_type", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["content", "example1 Maggie Gerlach"], ["created_at", Mon, 28 Oct 2013 18:06:58 UTC +00:00], ["searchable_id", 1], ["searchable_type", "User"], ["updated_at", Mon, 28 Oct 2013 18:06:58 UTC +00:00]] | |
(0.3ms) COMMIT | |
NoMethodError: undefined method `each' for 20:Fixnum | |
from /usr/local/rvm/rubies/ruby-2.0.0-p0/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/associations/collection_association.rb:333:in `replace' |
This file contains hidden or 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
# Read about factories at https://github.com/thoughtbot/factory_girl | |
FactoryGirl.define do | |
factory :tournament do | |
sequence(:title) {|n| "Tournament#{n}"} | |
game 'League of Legends' | |
starts_at 1.minute.since | |
association :owner, factory: :user | |
trait :with_teams do | |
mode 'team' | |
after :create do |tournament, evaluator| | |
FactoryGirl.create_list :tournament_membership, evaluator.teams, team: team, tournament: tournament | |
end | |
end | |
trait :with_users do | |
mode 'individual' | |
after :create do |tournament, evaluator| | |
FactoryGirl.create_list :tournament_membership, evaluator.users, user: user, tournament: tournament | |
end | |
end | |
end | |
end |
This file contains hidden or 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
FactoryGirl.define do | |
factory :user do | |
sequence(:username) { |n| "example#{n}"} | |
first_name Faker::Name.first_name | |
last_name Faker::Name.last_name | |
email { "#{username}@example.com" } | |
password "password" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment