Hi,... I am having trouble with label reference in fixtures... I have two fixtures like this : ### cars.yml one: name: Ferari two: name: Volvo ### drivers.yml one: name: Stall car: Ferari ''Drivers'' table have a ''belongs_to'' clause to the ''cars'' table, vice versa with ''has_many'' Evertime i am running my test, and access the ''drivers(:one).car'', I always get nil result. Can some one tell me where my mistake? Thanks in advance,
On Oct 14, 8:34 am, Stallion <albert.anthony...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi,... > > I am having trouble with label reference in fixtures... > > I have two fixtures like this : > > ### cars.yml > one: > name: Ferari > two: > name: Volvo > > ### drivers.yml > one: > name: Stall > car: Ferari > > ''Drivers'' table have a ''belongs_to'' clause to the ''cars'' table, vice > versa with ''has_many'' >That should be car: one - You reference the fixture label, not any of the data inside it. Fred> Evertime i am running my test, and access the ''drivers(:one).car'', I > always get nil result. > > Can some one tell me where my mistake? > > Thanks in advance,
2009/10/14 Stallion <albert.anthony.27-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > Hi,... > > I am having trouble with label reference in fixtures... > > I have two fixtures like this : > > ### cars.yml > one: > name: FerariThis should be Ferari: name: Ferari> two: > name: Volvo > > ### drivers.yml > one: > name: Stall > car: FerariThe Ferari here refers to Ferari: above, not to the name field, which is a column in the db. They need not be the same. Colin> > ''Drivers'' table have a ''belongs_to'' clause to the ''cars'' table, vice > versa with ''has_many'' > > Evertime i am running my test, and access the ''drivers(:one).car'', I > always get nil result.
On Wed, Oct 14, 2009 at 4:55 AM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Oct 14, 8:34 am, Stallion <albert.anthony...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Hi,... >> >> I am having trouble with label reference in fixtures... >> >> I have two fixtures like this : >> >> ### cars.yml >> one: >> name: Ferari >> two: >> name: Volvo >> >> ### drivers.yml >> one: >> name: Stall >> car: Ferari >> >> ''Drivers'' table have a ''belongs_to'' clause to the ''cars'' table, vice >> versa with ''has_many'' >> > > That should be car: one - You reference the fixture label, not any of > the data inside it.And I''d recommend making the ''ids'' more intention revealing ### cars.yml luigis_car: name: Ferari svens_car: name: Volvo ### drivers.yml luigi: name: Stall car: luigis_car -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale