# Why can't I save to a join table in a migration or rake task

**URL:** <https://www.ruby-forum.com/t/why-cant-i-save-to-a-join-table-in-a-migration-or-rake-task/103860>\
**Category:** Rails\
**Created:** [May 11, 2007, 1:48am UTC](https://www.ruby-forum.com/t/why-cant-i-save-to-a-join-table-in-a-migration-or-rake-task/103860 "2007-05-11T01:48:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [May 11, 2007, 1:48am UTC](https://www.ruby-forum.com/t/why-cant-i-save-to-a-join-table-in-a-migration-or-rake-task/103860/1 "2007-05-11T01:48:49Z")

</div>

I’ve tried to put this in a migration and in a rake task but nothing  
gets created in the roles\_users join table:

User.find(:all).each {|u| u.roles \<\< member\_role; u.save! }

## It works fine from script/console.

- Stephen B.  
Concord Consortium, [http://www.concord.org](http://www.concord.org)
