# Fixtures and associations

**URL:** <https://www.ruby-forum.com/t/fixtures-and-associations/155866>\
**Category:** RSpec\
**Created:** [December 17, 2008, 7:47pm UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866 "2008-12-17T19:47:29Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 17, 2008, 7:47pm UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/1 "2008-12-17T19:47:29Z")

</div>

Hello… I want ask for a help in error that don’t understand.

I have properties model and tenants model. Tenant belongs to Property  
and  
Property has many Tenants… I try this test association but allways get  
“not valid” error for association. Anyone can help? I post all my  
classes  
below:

My Tenant class:  
class Tenant \< ActiveRecord::Base  
belongs\_to :property

validates\_associated :property  
validates\_presence\_of :property  
…

My tenant\_spec.rb  
describe Tenant do  
fixtures :properties

def create\_tenant(options = {})  
record = Tenant.create({  
:property =\> properties(:two),  
:renters =\> “value for renters”,  
:guarantor =\> “value for guarantor”,  
:contact\_name =\> “value for contact\_name”,  
:contact\_phone =\> “value for contact\_phone”,  
:contact\_email =\> “removed\_email\_address@domain.invalid”,  
:end\_date =\> Date.today,  
:beginning\_date =\> Date.today,  
:initial\_value =\> “9.99”  
}.merge(options))  
end

before(:each) do  
@tenant = create\_tenant  
end

it “should create a new instance given valid attributes” do  
@tenant.errors.should be\_blank  
end  
…

My property\_spec.rb  
class Property \< ActiveRecord::Base  
has\_many :tenants  
…

My properties.yml:  
two:  
user: aaron  
owner: tania  
address: Rua de teste  
address\_number: 250  
neighborhood: Bairro ABC  
country\_state: MG  
country: Brasil  
city: Belo Horizonte  
cep: 30566500  
area: 150m  
constructed\_area: 120m  
category: galpÃ£o  
usage: comercial  
owner\_code: AS341ADV  
garage: 2  
description: Casa com 3 quartos  
observation:  
condominium\_value: 0  
iptu\_value: 90.50

Atenciosamente,

Daniel L. ï£¿ Area CriaÃ§Ãµes  
Design, Websites e Sistemas Web

Visite: [http://www.areacriacoes.com.br/projects](http://www.areacriacoes.com.br/projects)  
[http://blog.areacriacoes.com.br/](http://blog.areacriacoes.com.br/)

* * *

- 
  - 

- 

55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 17, 2008, 8:31pm UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/2 "2008-12-17T20:31:39Z")

</div>

On Wed, Dec 17, 2008 at 12:37 PM, Daniel L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> validates\_presence\_of :property  
> :contact\_phone =\> “value for contact\_phone”,
> 
> user: aaron  
> category: galpÃ£o  
> usage: comercial  
> owner\_code: AS341ADV  
> garage: 2  
> description: Casa com 3 quartos  
> observation:  
> condominium\_value: 0  
> iptu\_value: 90.50

Hi Daniel,

Are both tenant\_spec and property\_spec failing? What are the failure  
messages you’re getting?

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 17, 2008, 8:42pm UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/3 "2008-12-17T20:42:17Z")

</div>

Hello David, the error is only in tenant\_spec … in property\_spec all  
my  
examples passed. The error is in “@tenant.errors.should be\_empty” line  
and  
the message is expected empty? to return true, got false  
If I use puts to print my @tenant object before the assertion I get  
those  
values:

#\<ActiveRecord::Errors:0x23aabf4  
@errors={“property”=\>[“is not valid”]},  
@base=#\<Tenant id: nil,  
property\_id: 996332877,  
renters: “value for renters”,  
guarantor: “value for guarantor”,  
contact\_name: “value for contact\_name”,  
contact\_phone: “value for contact\_phone”,  
end\_date: “2008-12-17”,  
beginning\_date: “2008-12-17”,  
initial\_value: #BigDecimal:239a4fc,‘0.999E1’,8(8),  
created\_at: nil,  
updated\_at: nil,  
contact\_email: “removed\_email\_address@domain.invalid”\>\>

Atenciosamente,

Daniel L. ï£¿ Area CriaÃ§Ãµes  
Design, Websites e Sistemas Web

Visite: [http://www.areacriacoes.com.br/projects](http://www.areacriacoes.com.br/projects)  
[http://blog.areacriacoes.com.br/](http://blog.areacriacoes.com.br/)

* * *

- 
  - 

- 

55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 17, 2008, 9:05pm UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/4 "2008-12-17T21:05:15Z")

</div>

Hi Daniel,

What happens when you do

properties(:two).valid?  
p properties(:two).errors

It looks like that fixture is not valid.

Pat

“Daniel L.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 17, 2008, 10:18pm UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/5 "2008-12-17T22:18:54Z")

</div>

You are loading the users fixtures. You need to change your fixtures  
line to read

fixtures :properties, :users

(and any other models’ fixtures you want to use)

I highly recommend ditching fixtures all together. You avoid funky shit  
like this, and you won’t have coupling between tests that occurs with  
fixtures, and you’ll be able to create more clear specs because you do  
all the setup in the spec itself. If you’re interested, look into  
something like fixtures\_replacement, factory girl, object daddy, etc.  
Personally, I use a little 15-line homebrew framework.

Pat

“Daniel L.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 17, 2008, 9:30pm UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/6 "2008-12-17T21:30:03Z")

</div>

I get cannot be null error user in active record object… like below:  
properties(:two).valid? return false, but I don’t understand why…  
because  
my properties.yml file is like below:

two:  
user: aaron  
owner: tania  
address: Rua de teste  
address\_number: 250  
neighborhood: Bairro ABC  
…

and my users.yml is:

aaron:  
id: 2  
login: aaron  
name: aaron lorem  
email: removed\_email\_address@domain.invalid  
…

But my activerecord object return this:

#\<ActiveRecord::Errors:0x239be10 @errors={“user”=\>[“can’t be blank”]},  
@base=#\<Property id: 996332877,  
user\_id: 317248456,  
owner\_id: 465176508,  
address: “Rua de teste”,  
address\_number: “250”,  
neighborhood: “Bairro ABC”,  
country: “Brasil”,  
city: “Belo Horizonte”,  
area: “150m”,  
constructed\_area: “120m”,  
category: “galpÃ£o”,  
usage: “comercial”,  
owner\_code: “AS341ADV”,  
condominium\_value: #BigDecimal:2389274,‘0.0’,4(8),  
iptu\_value: #BigDecimal:2389238,‘0.905E2’,8(8),  
garage: 2,  
description: “Casa com 3 quartos”,  
observation: nil,  
cep: “30566500”,  
country\_state: “MG”,  
created\_at: “2008-12-17 20:11:11”,  
updated\_at: “2008-12-17 20:11:11”,  
zoning: “z10” \>\>

But it is not blank. What i’m doing wrong on my fixtures files? I think  
I  
don’t get the message yet in other model spec because this is the fist  
model  
that use properties.yml ( in properties\_spec I only use fixtures for  
users )

Atenciosamente,

Daniel L. ï£¿ Area CriaÃ§Ãµes  
Design, Websites e Sistemas Web

Visite: [http://www.areacriacoes.com.br/projects](http://www.areacriacoes.com.br/projects)  
[http://blog.areacriacoes.com.br/](http://blog.areacriacoes.com.br/)

* * *

- 
  - 

- 

55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 18, 2008, 12:43am UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/7 "2008-12-18T00:43:11Z")

</div>

On 17 Dec 2008, at 21:07, Pat M. wrote:

> I highly recommend ditching fixtures all together. You avoid funky  
> shit  
> like this, and you won’t have coupling between tests that occurs with  
> fixtures, and you’ll be able to create more clear specs because you do  
> all the setup in the spec itself. If you’re interested, look into  
> something like fixtures\_replacement, factory girl, object daddy, etc.

+1

You’ll never look back.

Matt W.

> **[Tea-Driven Development – Matt Wynne taking it one tea at a time](http://blog.mattwynne.net)**

> **[Find the Best Concerts Near You, Tour Dates & Tickets Worldwide | Songkick](https://www.songkick.com)**
>
> Find live music near you, track your favorite artists, get instant concert alerts and buy tickets for all the best upcoming concerts.

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 17, 2008, 11:35pm UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/8 "2008-12-17T23:35:46Z")

</div>

Hello Pat, even I load all my fixtures it still not reading anything  
from  
users.yml …  
I will look at factory\_girl but before I need understand what happening.

I try this:

require File.expand\_path(File.dirname( **FILE** ) + ‘/…/spec\_helper’)

describe Tenant do  
fixtures :properties, :users , :owners

def create\_tenant(options = {})  
record = Tenant.create({  
:property =\> properties(:two),  
:renters =\> “value for renters”,  
:guarantor =\> “value for guarantor”,  
:contact\_name =\> “value for contact\_name”,  
:contact\_phone =\> “value for contact\_phone”,  
:contact\_email =\> “removed\_email\_address@domain.invalid”,  
:end\_date =\> Date.today,  
:beginning\_date =\> Date.today,  
:initial\_value =\> “9.99”  
}.merge(options))  
end

before(:each) do  
@tenant = create\_tenant  
end

it “should create a new instance given valid attributes” do  
p properties(:two).errors  
properties(:two).should be\_valid  
# @tenant.errors.should be\_empty  
end

end

Atenciosamente,

Daniel L. ï£¿ Area CriaÃ§Ãµes  
Design, Websites e Sistemas Web

Visite: [http://www.areacriacoes.com.br/projects](http://www.areacriacoes.com.br/projects)  
[http://blog.areacriacoes.com.br/](http://blog.areacriacoes.com.br/)

* * *

- 
  - 

- 

55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 18, 2008, 1:41am UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/9 "2008-12-18T01:41:07Z")

</div>

Hello Pat, the error still the same.@errors={“user”=\>[“can’t be blank”]}

But if we look on @base we have user:  
@base=#\<Property id: 996332877, user\_id: 317248456, owner\_id: 465176508,  
…

> 

And my code is:  
describe Tenant do  
fixtures :properties, :users ,:owners

def create\_tenant(options = {})  
record = Tenant.create({  
:property =\> properties(:two),  
:renters =\> “value for renters”,  
:guarantor =\> “value for guarantor”,  
:contact\_name =\> “value for contact\_name”,  
:contact\_phone =\> “value for contact\_phone”,  
:contact\_email =\> “[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)”,  
:end\_date =\> Date.today,  
:beginning\_date =\> Date.today,  
:initial\_value =\> “9.99”  
}.merge(options))  
end

before(:each) do  
@tenant = create\_tenant  
end

it “should create a new instance given valid attributes” do  
properties(:two).valid?  
p properties(:two).errors  
# @tenant.errors.should be\_empty  
end

And my fixtures still the same… I don’t know what’s happening, when I  
try  
run on console or in browser everything ok… I think is something  
strange  
with fixtures.

Atenciosamente,

Daniel L. ï£¿ Area CriaÃ§Ãµes  
Design, Websites e Sistemas Web

Visite: [http://www.areacriacoes.com.br/projects](http://www.areacriacoes.com.br/projects)  
[http://blog.areacriacoes.com.br/](http://blog.areacriacoes.com.br/)

* * *

- 
  - 

- 

55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 18, 2008, 1:46am UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/10 "2008-12-18T01:46:58Z")

</div>

On Thu, Dec 18, 2008 at 1:38 AM, Daniel L.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> def create\_tenant(options = {})  
> record = Tenant.create({

Just a small tip. Always, always use create! in specs. You want an error  
to  
be raised in case creation is unsuccessful, and create doesn’t do that -  
it  
just returns false.

Aslak

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 18, 2008, 2:46am UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/11 "2008-12-18T02:46:01Z")

</div>

I know… I just don’t use create!, in this special case, because it  
will be  
more complicate to know what field have the error .  
I’m still scratching my head, my @tenant instance var on spec has values  
for  
user\_id and owner\_id and don’t understand why my validates\_associated  
:property raise an error.

And if I mock model on model spec will not be a good thing.

Atenciosamente,

Daniel L. ï£¿ Area CriaÃ§Ãµes  
Design, Websites e Sistemas Web

Visite: [http://www.areacriacoes.com.br/projects](http://www.areacriacoes.com.br/projects)  
[http://blog.areacriacoes.com.br/](http://blog.areacriacoes.com.br/)

* * *

- 
  - 

- 

55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501

On Wed, Dec 17, 2008 at 10:45 PM, aslak hellesoy

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 18, 2008, 3:14am UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/12 "2008-12-18T03:14:41Z")

</div>

On Thu, Dec 18, 2008 at 2:02 AM, Daniel L.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> I know… I just don’t use create!, in this special case, because it will  
> be more complicate to know what field have the error .

No it won’t. The error message tells you what field has the error, and  
if  
creation is unsuccessful you _need_ to know about it. Otherwise you’ll  
get  
tons of false positives. I can’t think of a single case where it makes  
sense  
to use create inside a spec.

Aslak

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 18, 2008, 3:49am UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/13 "2008-12-18T03:49:51Z")

</div>

I think I was misunderstood. I am not saying to use create rather than  
create! … In this case, I just use it because will help me with puts  
for  
debug my own error in spec.  
In this case a really don’t know what is going on, if I use create! I  
can’t  
store the value in a var and then try to look what is the message of the  
failed attribute with puts.  
I using puts to print the error object to debug who is the wrong  
attribute.  
If I use create! I will have this message:  
Validation failed: Property is not valid =\> and cant use puts to know  
the  
content of @errors

If I use create and print the result of fixture I will get:

\<ActiveRecord::Errors:0x23af4b0 @errors={“user”=\>[“nÃ£o pode ser  
vazio”]},  
@base=#\<Property id: 996332877, user\_id: 317248456, …

And find the problem, it is just for debugging and help me to find where  
is  
the problem, after fix this I will change to create! again.

–

Anyone can figure why even property\_id and owner\_id are defined still  
raise  
“can’t be blank” ?

Thanks a lot for all help.

Atenciosamente,

Daniel L. ï£¿ Area CriaÃ§Ãµes  
Design, Websites e Sistemas Web

Visite: [http://www.areacriacoes.com.br/projects](http://www.areacriacoes.com.br/projects)  
[http://blog.areacriacoes.com.br/](http://blog.areacriacoes.com.br/)

* * *

- 
  - 

- 

55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501

On Thu, Dec 18, 2008 at 12:10 AM, aslak hellesoy

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 18, 2008, 1:17am UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/14 "2008-12-18T01:17:09Z")

</div>

On Wed, Dec 17, 2008 at 2:13 PM, Daniel L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ```
> :renters => "value for renters",
> 
> ```
> 
> before(:each) do  
> @tenant = create\_tenant  
> end
> 
> it “should create a new instance given valid attributes” do  
> p properties(:two).errors  
> properties(:two).should be\_valid  
> # @tenant.errors.should be\_empty  
> end  
> end

What error are you getting now? Please post whatever error you’re  
experiencing…when we change this code, I expect a different error,  
and would not know what it is. If it’s the same, that’s strange.

Also, I noticed you have  
p properties(:two).errors  
properties(:two).should be\_valid

That’s not going to show you anything, because errors don’t get added  
until you call #valid? So change that to

properties(:two).valid?  
p properties(:two).errors

Pat

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 18, 2008, 4:49pm UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/15 "2008-12-18T16:49:58Z")

</div>

I really don’t know what’s going on with those hell fixtures, and start  
thinking I will never find… I will try migrate all my fixtures to  
factory-girl, the only problem are my six hundred examples and no time  
to  
change all. Somebody have any link about rspec + factory-girl ? or maybe  
link to any project on github that use factory-girl and rspec ?  
Thanks for all help.

Atenciosamente,

Daniel L. ï£¿ Area CriaÃ§Ãµes  
Design, Websites e Sistemas Web

Visite: [http://www.areacriacoes.com.br/projects](http://www.areacriacoes.com.br/projects)  
[http://blog.areacriacoes.com.br/](http://blog.areacriacoes.com.br/)

* * *

- 
  - 

- 

55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 18, 2008, 5:36pm UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/16 "2008-12-18T17:36:23Z")

</div>

[http://toolmantim.com/article/2008/10/27/fixtureless\_datas\_with\_machinist\_and\_sham](http://toolmantim.com/article/2008/10/27/fixtureless_datas_with_machinist_and_sham)

> **[Cucumbers & Factory Girls](https://www.slideshare.net/toolmantim/cucumbers-presentation)**
>
> CUCUMBERS! AND FACTORY GIRLS CUCUMBER STORIES 210 SCENARIOS BIG BULLSHIT NUMBERS In order to show the world how cool they are A user Should be able t...

> **[GitHub - tpope/pickler: PIvotal traCKer Liaison to cucumbER](https://github.com/tpope/pickler/tree/master)**
>
> master

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 18, 2008, 5:33pm UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/17 "2008-12-18T17:33:26Z")

</div>

On Thu, Dec 18, 2008 at 7:24 AM, Daniel L.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> I really don’t know what’s going on with those hell fixtures, and start  
> thinking I will never find… I will try migrate all my fixtures to  
> factory-girl, the only problem are my six hundred examples and no time to  
> change all.

You don’t have to change all your fixtures to factories right now, of  
course, and, indeed, you should not. Just change the ones that are  
giving  
you problems for now; and later, maybe, change each on as you work on  
it.

///

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 18, 2008, 5:39pm UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/18 "2008-12-18T17:39:19Z")

</div>

oops  
that last one was supposed to be

> **[GitHub - ianwhite/pickle: Easy model creation/reference in cucumber - optionally...](https://github.com/ianwhite/pickle/tree/master)**
>
> master

similar names

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 18, 2008, 6:44pm UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/19 "2008-12-18T18:44:58Z")

</div>

Thanks everybody…  
Atenciosamente,

Daniel L. ï£¿ Area CriaÃ§Ãµes  
Design, Websites e Sistemas Web

Visite: [http://www.areacriacoes.com.br/projects](http://www.areacriacoes.com.br/projects)  
[http://blog.areacriacoes.com.br/](http://blog.areacriacoes.com.br/)

* * *

- 
  - 

- 

55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [December 18, 2008, 5:37pm UTC](https://www.ruby-forum.com/t/fixtures-and-associations/155866/20 "2008-12-18T17:37:33Z")

</div>

So, I think the problem is my fixture became crazy with id’s and not  
assign  
the right id for the right object in association when I try use Rails 2  
sintax for fixtures ( omitting the ids and using the name of the fixture  
in  
the association instead of id ) … when I change everything to fixed id  
in  
my yml files everything works.  
Crazy. I’m still want to migrate to factory-girl, if anybody has  
material or  
links on github about projects using rspec and factory-girl will help  
alot.

Atenciosamente,

Daniel L. ï£¿ Area CriaÃ§Ãµes  
Design, Websites e Sistemas Web

Visite: [http://www.areacriacoes.com.br/projects](http://www.areacriacoes.com.br/projects)  
[http://blog.areacriacoes.com.br/](http://blog.areacriacoes.com.br/)

* * *

- 
  - 

- 

55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501
