Guest User

Untitled

a guest
Jan 16th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. pos=item.category.items.map(&:id)
  2. current_position=pos.index(id.to_i)
  3. item.save # want to refresh the relationship here
  4. pos_new=item.categoty.items.map(&:id)
  5. # grabbing this since just accessing item isn't updated if positioning has changed
  6. item_new=Item.find(id)
  7. pos_new=item_new.category.items.map(&:id)
  8. new_position=pos_new.index(id)
  9. if current_position!=new_position
  10. is_moved=true # sent back in JSON to propagate a dynamic change.
  11. end
Add Comment
Please, Sign In to add comment