I am using Rails 4 and the ActsAsList gem to give our Project model a position. Projects can be owned my one user, and collaborated on with many users. When a user re-orders their projects, it affects the project order for the collaborators as an unintended side-effect. Is there a way around this?
1 Answer
UPDATE
Based on @nate's suggestion, I moved the :position
column from the Project
model to the Collaboration
model which is the join table between Project
and User
. Then I included acts_as_list scope: :user_id
on the Collaboration
model and removed it from the Project
model. Now each user
has projects
through collaborations
and the position of each project
is scoped to the user
.
scope
option on theacts_as_list
gem and give it a symbol of the column name that you want it to scope to. github.com/swanandp/acts_as_list/blob/master/README.md#example It sounds like you have the position on the wrong table though. Without seeing your models it’s hard to tell for sure, but I would say that your project shouldn’t have a position column but instead the join table between projects and collaborators should. This will allow you to scope the acts_as_list on the collaborators_projects table to collaborator_id (given the join table idea).