# HABTM fixtures issue

**URL:** <https://www.ruby-forum.com/t/habtm-fixtures-issue/147621>\
**Category:** Rails\
**Created:** [September 3, 2008, 5:57pm UTC](https://www.ruby-forum.com/t/habtm-fixtures-issue/147621 "2008-09-03T17:57:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [September 3, 2008, 5:57pm UTC](https://www.ruby-forum.com/t/habtm-fixtures-issue/147621/1 "2008-09-03T17:57:11Z")

</div>

Hi all , (environment : Rails 2.1, Authorization Plugin)

I am setting up fixtures (w autogenerated IDs) , but I am stuck with  
the following issue w the roles\_users table

I have a users.yaml fixtures file w following info

DEFAULTS: &DEFAULTS  
created\_at: \<%= 15.days.ago.to\_s(:db) %\>  
updated\_at: \<%= 15.days.ago.to\_s(:db) %\>  
activated\_at: \<%= 15.days.ago.to\_s :db %\>  
mickey:  
first\_name: mickey  
last\_name: rourcke  
email: removed\_email\_address@domain.invalid  
franchise: two  
state: active  
\<\<: \*DEFAULTS  
…

I can define the HABTM relation directly into the ‘roles.yaml’  
fixtures file as follows :

DEFAULTS: &DEFAULTS  
created\_at: \<%= 15.days.ago.to\_s(:db) %\>  
updated\_at: \<%= 15.days.ago.to\_s(:db) %\>  
…  
administrator\_of\_two:  
name: administrator  
authorizable: two (Franchise)  
users: mickey  
\<\<: \*DEFAULTS

no need for a users\_roles.yaml file the users\_roles data are created  
into the table, BUT…  
the timestamps ARE NOT set in the roles\_users table…

any clue ?

thanks

erwin

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [September 4, 2008, 2:01am UTC](https://www.ruby-forum.com/t/habtm-fixtures-issue/147621/2 "2008-09-04T02:01:52Z")

</div>

On 3 Sep 2008, at 09:23, Erwin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi all , (environment : Rails 2.1, Authorization Plugin)
> 
> I am setting up fixtures (w autogenerated IDs) , but I am stuck with  
> the following issue w the roles\_users table

Extra attributes on habtm join tables is kinds deprecated, so I  
wouldn’t be surprised if the foxy fixtures stuff (which was only added  
in 2.0) didn’t support it.

Fred

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [September 4, 2008, 3:13am UTC](https://www.ruby-forum.com/t/habtm-fixtures-issue/147621/3 "2008-09-04T03:13:50Z")

</div>

I modified the fixtures.rb , according to the patch, and it runs  
well… I get the timestamps OK in the generated users\_roles table…  
even if HABTM is deprecated, the Authorization Plugin is still using  
it… good question asked in Authorization Plugin group

thanks

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [September 4, 2008, 10:30am UTC](https://www.ruby-forum.com/t/habtm-fixtures-issue/147621/4 "2008-09-04T10:30:25Z")

</div>

On 3 Sep 2008, at 09:54, Erwin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi Fred, thanks for being there…
> 
> I looked into activerecord-2.1.0/lib/active\_record/fixtures.rb to  
> see if the foxy fixtures stuff was there… it’s not (I discovered  
> this patch goggling a little bit…)

It must be or you’d have to have a user\_roles.yml file. Foxy fixtures  
is just a name - I wouldn’t be surprised if that string didn’t appear  
anywhere in it

Fred

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [September 4, 2008, 2:58am UTC](https://www.ruby-forum.com/t/habtm-fixtures-issue/147621/5 "2008-09-04T02:58:02Z")

</div>

Hi Fred, thanks for being there…

I looked into activerecord-2.1.0/lib/active\_record/fixtures.rb to  
see if the foxy fixtures stuff was there… it’s not (I discovered  
this patch goggling a little bit…)

I 'll try to patch it… but I neved did that before…  
once I get the .diff file, how can I do that ? I can suppress/add  
lines by hand, but I suppose there is a fancy way to do it

erwin
