itmammoth / rails_sortable

Easy drag & drop sorting with persisting the arranged order for rails
MIT License
142 stars 37 forks source link

Does not work with UUIDs #27

Closed lewaabahmad closed 4 years ago

lewaabahmad commented 6 years ago

After looking through the logs and the source code, I found that the .to_i method was being used to get the id of the sortable model. This would therefore not allow for the sorting of models that uses anything but integer values as ids.

  def find_model(klass_to_id)
    klass, id = klass_to_id.values_at('klass', 'id')
    klass.constantize.find(id.to_i)
  end

method found here: https://github.com/itmammoth/rails_sortable/blob/master/app/controllers/sortable_controller.rb#L21

If this assessment is correct, I'd be happy to make a PR to try and fix it over the next week or two. Otherwise, please excuse me for bringing up a mute point. I'd love to hear what I'm getting wrong.

itmammoth commented 6 years ago

Your assessment is perfectly correct. I missed the case that id was not an integer.

I'm looking forward to your PR. Thanks.

itmammoth commented 4 years ago

55217628ca3393b048b9702139eb645b4d3132a5