factory_girlでhas_manyを作る
factory_girlでpogepoge:hoge 1:nの関係を作ろうとしてます。
下記のように作成したのですが
FactoryGirl.define do
factory :pogepoge do
association :user, factory: :user
hoge 1
birthday Date.today - 20.year
after(:create) do |pogepoge|
create(:hoge, pogepoge: pogepoge)
end
end
end
下記validationでエラーになってしまいます。
def hoge_exist
if hoge.blank?
errors.add(:hoge, :no_hoge)
end
end
エラーにしない方法を知りたいです。
エラー内容は以下のような形で出ます。
ActiveRecord::RecordInvalid:
translation missing: ja.activerecord.errors.messages.record_invalid
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/configuration.rb:14:in `block in initialize'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/evaluation.rb:15:in `[]'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/evaluation.rb:15:in `create'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/strategy/create.rb:12:in `block in result'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/strategy/create.rb:9:in `tap'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/strategy/create.rb:9:in `result'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/factory.rb:42:in `run'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/factory_runner.rb:23:in `block in run'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/factory_runner.rb:22:in `run'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/strategy/create.rb:5:in `association'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/evaluator.rb:31:in `association'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/attribute/association.rb:19:in `block in to_proc'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/evaluator.rb:71:in `instance_exec'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/evaluator.rb:71:in `block in define_attribute'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:56:in `get'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:15:in `each'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:14:in `tap'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:14:in `object'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/evaluation.rb:12:in `object'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/strategy/create.rb:9:in `result'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/factory.rb:42:in `run'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/factory_runner.rb:23:in `block in run'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/factory_runner.rb:22:in `run'
# /Users/hoge/.rbenv/versions/2.2.4/gemsets/ruby224/gems/factory_girl-4.5.0/lib/factory_girl/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'