Model
Material
User
Materials_Users(Join table)
In console, when I try material.user_ids = [1,2] , it works well. But when I try to insert element one by one, like material.user_ids << 3 , it does not work, the array turn to empty and nothing is inserted into the array.
How to solve this problem?
material.user_idsbefore appending with<<? What do you mean by "it does not work"? How exactly did you diagnose this? Many things could have gone wrong, so being specific is important. For example, add an excerpt from what you did on the Rails console. Also, please improve your writing. It is riddled with errors.