# People(:sam) should be saved to a @sam variable?

**URL:** <https://www.ruby-forum.com/t/people-sam-should-be-saved-to-a-sam-variable/177086>\
**Category:** Rails\
**Created:** [October 11, 2009, 11:15am UTC](https://www.ruby-forum.com/t/people-sam-should-be-saved-to-a-sam-variable/177086 "2009-10-11T11:15:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [October 11, 2009, 11:15am UTC](https://www.ruby-forum.com/t/people-sam-should-be-saved-to-a-sam-variable/177086/1 "2009-10-11T11:15:45Z")

</div>

Hi all

When creating unit tests, I wondered whether I should rather use the  
following…

people(:sam).name = “Sammy”  
people(:sam).city = “Blah”

…or rather the following form:

@sam = people(:sam)  
@sam.name = “Sammy”  
@sam.city = “Blah”

Thanks  
Josh

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [October 12, 2009, 4:47pm UTC](https://www.ruby-forum.com/t/people-sam-should-be-saved-to-a-sam-variable/177086/2 "2009-10-12T16:47:06Z")

</div>

Why would you want to do _either_? If you want your fixtures to have  
different data, just change them.

In any case, the second way is preferable; I’m not 100% sure that the  
first way won’t re-instantiate the fixture and zorch your changes.

–Matt J.

On Oct 11, 5:15 am, Joshua M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [October 12, 2009, 7:59pm UTC](https://www.ruby-forum.com/t/people-sam-should-be-saved-to-a-sam-variable/177086/3 "2009-10-12T19:59:03Z")

</div>

> I’m not 100% sure that the  
> first way won’t re-instantiate the fixture and zorch your changes.

That’s exactly the point I want to know. As far as I can see it doesn’t  
re-instantiate it…

Thanks!
