Hi
thanks a lot for this info... yeah, the documentation is not as
complete as a beginner would like to read ... ;-))
but that's not a big deal as I found a 'trick' ... I'll modify it
after the new callback syntax will be released ..
I have another issue in understanding how associations can be
defined ...
I am trying to create a Region inside an Area ' Area has_many
Region
I defined an Area Factory , creating instances with
FactoryGirl.create(:area, name: area_name) running OK
I defined a Region factory
FactoryGirl.define do
factory :region do
area
name
..
end
but trying to create a Region instance with :
area = Area.first => #<Area id: 18, name: "My New Area"..>
insee_code = "53"
new_region = FactoryGirl.create(:region, insee_code: region, area:
area)
I always get an error : TypeError: Cannot visit Area
If I use FactoryGirl.build(:region, insee_code: region, area: area), I
can see the region instance built ..
#<Region id: nil, area_id: 18, name: "Brittany",..>
so what happen with the save ?
I tried to modify the association ,association :area, factory: :area,
strategy: :build...
but same issue ..
where is it documented ?
thanks for your feedback
On May 10, 3:49 pm, Joe Ferris <
jfer...@thoughtbot.com> wrote:
> Hey,
>
> The new callback syntax hasn't been released yet. You'll want to write your callbacks like this:
>
> after_create { |instance| … }
>
> The documentation on Github can be confusing, since it shows everything in master, not all of which is released.
>
> -Joe
>
>
>
>
>
>
>
> On Thursday, May 10, 2012 at 2:42 AM, kadoudal wrote:
> > I guess I found a trick ( or may it's the way it should be done ..)
>
> > not using the after(:create) callback but rather adding :
> > factory :superadmin, :class => Admin do |a|
> > a.roles ['superadmin']
> > end
>
> > and creating the instance with like this :
> > FactoryGirl.create(:superadmin, email: .... )
>
> > Is that the way it should be done ?
>
> > To post to this group, send email to
factor...@googlegroups.com (mailto:
factor...@googlegroups.com)
> > To unsubscribe from this group, send email to
> >
factory_girl...@googlegroups.com (mailto:
factory_girl...@googlegroups.com)