rails_sortable 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/sortable_controller.rb +6 -4
- data/lib/rails_sortable/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01705f347272f2e9544157f20b53a4f44f37c832e4667b5bcae0ae4f9b22a679
|
4
|
+
data.tar.gz: e6f53da76738afc329ce03b66a1bf0b8c0ddf173823e539a44f2def4304e346a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2018-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|