rails_sortable 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35da2203e68df3155c4247c6d2c559dcad1afe71625b7c208140b07767a728aa
4
- data.tar.gz: 8203be170dd5a5d0530dbf2d35f155de0e0edd6f3e1d4f39b1462c83fb7dc9d8
3
+ metadata.gz: 01705f347272f2e9544157f20b53a4f44f37c832e4667b5bcae0ae4f9b22a679
4
+ data.tar.gz: e6f53da76738afc329ce03b66a1bf0b8c0ddf173823e539a44f2def4304e346a
5
5
  SHA512:
6
- metadata.gz: cf9ef9532ac87ed135803bbbfbb30a025874ae6d5c55986aad767be4ce2d05bafc8ea5dedfd6f04da969797aae7b0db1e30a1bf7929eb47a201bfb76748b78c6
7
- data.tar.gz: 674c3b4b74cc7f4aae0210336ed9323d5e4684c1791d41999b8ba65c3a7e5aa5b21ba3e14b40045bfd280a8cc4abc24a73057864b8cde23429bf4d378225874c
6
+ metadata.gz: 9ab23e31ad194de437dbef8da948b4cfa9b2a8148e02a1eeaa41bf66dba76f4741c06dfa02b2e56cdd1d6c29c0d4354e6481e1ddf1cf87c508e6803058fe1c22
7
+ data.tar.gz: 5cc3196b8b6e00e426ea153f21cef5234e20813c882b9a64e5eea1b4b20347789707529fb3dea204fb875d954129538dbf945ab09f70aea71a9a0d29a3e4fc52
@@ -5,10 +5,12 @@ class SortableController < ApplicationController
5
5
  def reorder
6
6
  klass, ids = parse_params
7
7
  attr = klass.sort_attribute
8
- id_to_model = klass.find(ids).index_by(&:id)
9
- ids.each_with_index do |id, new_sort|
10
- model = id_to_model[id]
11
- model.update_sort!(new_sort) if model.read_attribute(attr) != new_sort
8
+ ActiveRecord::Base.transaction do
9
+ id_to_model = klass.find(ids).index_by(&:id)
10
+ ids.each_with_index do |id, new_sort|
11
+ model = id_to_model[id]
12
+ model.update_sort!(new_sort) if model.read_attribute(attr) != new_sort
13
+ end
12
14
  end
13
15
 
14
16
  head :ok
@@ -1,3 +1,3 @@
1
1
  module RailsSortable
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_sortable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - itmammoth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-16 00:00:00.000000000 Z
11
+ date: 2018-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal