In my rails app I have two models that are related by has_and_belongs_to_many. This means there is a join table.
Imagine the scenario where I am adding users to a game. If I want to add a user, I do:
@game.users << @user
Supposing that I want to know in what order I added these users. I can do this:
@game.users.each do....
My questions are:
Is the ordering if this list guaranteed to read the same way each time?
If that's the case, What's a clean way to reorder the users in the game?
has_and_belongs_to_many :users, -> { order('users.id ASC') }
– Anarthria