daily pastebin goal


a guest Jan 16th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand