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

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs