# Fixtures and helper functions

**URL:** <https://www.ruby-forum.com/t/fixtures-and-helper-functions/143153>\
**Category:** Rails\
**Created:** [July 15, 2008, 7:21pm UTC](https://www.ruby-forum.com/t/fixtures-and-helper-functions/143153 "2008-07-15T19:21:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgreenly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85f322/32.png) [@mgreenly](https://www.ruby-forum.com/u/mgreenly)\
**Post date:** [July 15, 2008, 7:21pm UTC](https://www.ruby-forum.com/t/fixtures-and-helper-functions/143153/1 "2008-07-15T19:21:55Z")

</div>

I like the new fixture features for rails 2.1. However, I would like  
to define a mapper so I specify the IDs to be used, rather than a  
hash. This is for several simple reasons: For one, I can type the  
URLs out a lot easier if the ID is 12 vs 12351231. For two, I am  
maintaining will-be live data in fixtures, and when I flip the switch  
and make it actually live, I would rather not have to deal with new  
IDs starting in the millions.

So, I know I can do this with ERB:

\<%  
@current\_id = 1  
def next\_id  
@current\_id += 1  
end

\<%= next\_id %\>:  
id: \<%= map\_name(:quicktiger) %\>  
name: Quicktiger  
…

The thing is, I will want to use this map\_name function from many  
fixtures. However, I cannot seem to find the right place to put it so  
I can access it from all fixure files. Is there a fixture helper  
somewhere that I’m not aware of?

–Michael
