# Finding out the file attributes in FileColumn models

**URL:** <https://www.ruby-forum.com/t/finding-out-the-file-attributes-in-filecolumn-models/60537>\
**Category:** Rails\
**Created:** [May 15, 2006, 11:57am UTC](https://www.ruby-forum.com/t/finding-out-the-file-attributes-in-filecolumn-models/60537 "2006-05-15T11:57:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Douglas\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecccb3/32.png) [@Douglas\_T](https://www.ruby-forum.com/u/Douglas_T)\
**Post date:** [May 15, 2006, 11:57am UTC](https://www.ruby-forum.com/t/finding-out-the-file-attributes-in-filecolumn-models/60537/1 "2006-05-15T11:57:39Z")

</div>

Is there a way to find out the attributes that have been passed to  
file\_column in models? I’ve looked through the source and it seems that  
the  
file\_column methods are generated at runtime but there’s actually no  
class  
or instance variable that hold the file attribute.

---

<div class="post-metadata">

**Author:** ![Douglas\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecccb3/32.png) [@Douglas\_T](https://www.ruby-forum.com/u/Douglas_T)\
**Post date:** [May 16, 2006, 10:55am UTC](https://www.ruby-forum.com/t/finding-out-the-file-attributes-in-filecolumn-models/60537/2 "2006-05-16T10:55:05Z")

</div>

consider this itch scratched, spent 1.5 days trying to understand the  
Fixtures and the FileColumn module. Got it to work by extending the  
FileColumn module with a class variable that stores the attribute value  
passed to file\_column.

I wanted to have a way to know the file attribute as I needed a way to  
automatically create files for the fixtures which are for models with  
file\_column attributes. Once I figured out how to retrieve the file  
attributes for each model, this became trivial to implement.

---

<div class="post-metadata">

**Author:** ![Douglas\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecccb3/32.png) [@Douglas\_T](https://www.ruby-forum.com/u/Douglas_T)\
**Post date:** [May 17, 2006, 5:13am UTC](https://www.ruby-forum.com/t/finding-out-the-file-attributes-in-filecolumn-models/60537/3 "2006-05-17T05:13:20Z")

</div>

I’ll be posting an entry on my blog about this soon, so stay tuned?

---

<div class="post-metadata">

**Author:** ![Douglas\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecccb3/32.png) [@Douglas\_T](https://www.ruby-forum.com/u/Douglas_T)\
**Post date:** [May 16, 2006, 8:51pm UTC](https://www.ruby-forum.com/t/finding-out-the-file-attributes-in-filecolumn-models/60537/4 "2006-05-16T20:51:38Z")

</div>

Douglas T. wrote:

> I wanted to have a way to know the file attribute as I needed a way to  
> automatically create files for the fixtures which are for models with  
> file\_column attributes. Once I figured out how to retrieve the file  
> attributes for each model, this became trivial to implement.

I run into same problem today when I was writing tests for model which  
uses file\_column. Any change for sharing how you did the fixture file  
creation?

---

<div class="post-metadata">

**Author:** ![Douglas\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecccb3/32.png) [@Douglas\_T](https://www.ruby-forum.com/u/Douglas_T)\
**Post date:** [May 17, 2006, 6:19am UTC](https://www.ruby-forum.com/t/finding-out-the-file-attributes-in-filecolumn-models/60537/5 "2006-05-17T06:19:23Z")

</div>

Great! I’ll be testing this today. Thanks a lot!

---

<div class="post-metadata">

**Author:** ![Douglas\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecccb3/32.png) [@Douglas\_T](https://www.ruby-forum.com/u/Douglas_T)\
**Post date:** [May 17, 2006, 6:01am UTC](https://www.ruby-forum.com/t/finding-out-the-file-attributes-in-filecolumn-models/60537/6 "2006-05-17T06:01:48Z")

</div>

here’s how I got automatic file creation for fixtures to work  
[http://www.practicalguile.com/articles/ruby/rails/automatically-creating-files-for-file\_column-models-in-fixtures/](http://www.practicalguile.com/articles/ruby/rails/automatically-creating-files-for-file_column-models-in-fixtures/)
