# Calculated fixtures

**URL:** <https://www.ruby-forum.com/t/calculated-fixtures/110769>\
**Category:** Rails\
**Created:** [July 30, 2007, 7:04pm UTC](https://www.ruby-forum.com/t/calculated-fixtures/110769 "2007-07-30T19:04:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xyzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/839c29/32.png) [@xyzt](https://www.ruby-forum.com/u/xyzt)\
**Post date:** [July 30, 2007, 7:04pm UTC](https://www.ruby-forum.com/t/calculated-fixtures/110769/1 "2007-07-30T19:04:08Z")

</div>

Hello,

I want to prepare fixtures to insert into the table. but one column  
needs to be calculated before inserting. For example, the password field  
must be recorded as MD5(password) (MD5 of password). how can i do this?

---

<div class="post-metadata">

**Author:** ![xyzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/839c29/32.png) [@xyzt](https://www.ruby-forum.com/u/xyzt)\
**Post date:** [July 30, 2007, 7:16pm UTC](https://www.ruby-forum.com/t/calculated-fixtures/110769/2 "2007-07-30T19:16:17Z")

</div>

On Mon, 30 Jul 2007, BahadÄ±r DoÄ~\_an wrote:

> Hello,
> 
> I want to prepare fixtures to insert into the table. but one column  
> needs to be calculated before inserting. For example, the password field  
> must be recorded as MD5(password) (MD5 of password). how can i do this?

Fixtures accept ERB templating syntax so you can put your  
calculations as ruby code between \<%= … %\> etc. See the recent  
thread about my problems using ERB which were actually due to bugs  
in my expanded code.

```
    HTH
    Hugh
```
