ruby on rails - NoMethodError: undefined method `to_sym' for {:factory=>:user}:Hash -


i error when call create on character factory

    factory :user |f|         f.sequence(:email) { |n| "foo#{n}@example.com" }         f.password "password"          end      factory :character |f|         f.name "testcharone"         f.race "human"     after(:create) { |character| character.init("fighter")}     association factory: :user   end 

error:

nomethoderror:        undefined method `to_sym' {:factory=>:user}:hash 

can see what's wrong?

this test took 16 minutes complete, while others, similiar took between 5-10 minutes

describe character        let(:character) { factorygirl.create :character}    describe "#add_units"           context "when unit doesnt exist beforehand"                   "it create new member"             expect(character.owns.count).to eq(0)             character.add_units("character", "archer" => 1)             expect(character.owns.count).to eq(1)             expect(character.owns.first.amount).to eq(1)         end     end 

in factory :character,

replace

 association factory: :user 

with

 association :user 

you have pass factory name i.e., :user in case , not hash factory: :user


Comments

Popular posts from this blog

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -