Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pos=item.category.items.map(&:id)
- current_position=pos.index(id.to_i)
- item.save # want to refresh the relationship here
- pos_new=item.categoty.items.map(&:id)
- # grabbing this since just accessing item isn't updated if positioning has changed
- item_new=Item.find(id)
- pos_new=item_new.category.items.map(&:id)
- new_position=pos_new.index(id)
- if current_position!=new_position
- is_moved=true # sent back in JSON to propagate a dynamic change.
- end
Add Comment
Please, Sign In to add comment