im have model Category.
class Category < ActiveRecord::Base
has_ancestry :cache_depth => true, :depth_cache_column => :depth
end
Category have field name. Im want to build a factory for category with depth level 2.
When this factory will be invoked it must build category level 2 and have parent category with level 1.
How to do this?
Im trying various tricks, all dont work. Im stop at something like that
Factory.define :category do |f|
f.name { Faker::Lorem.word }
f.parent { Factory.create(:category) }
end
Thank you!
Maybe you can create another factory, which has no parent.
And if you want to have you’re 2 level category you do:
The factory definition could be something like that:
Cheers