rails_sortable 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +61 -24
  3. data/app/helpers/sortable_helper.rb +4 -6
  4. data/app/models/rails_sortable/model.rb +8 -5
  5. data/lib/rails_sortable/core_ext/enumerable.rb +6 -0
  6. data/lib/rails_sortable/core_ext.rb +3 -0
  7. data/lib/rails_sortable/version.rb +1 -1
  8. data/lib/rails_sortable.rb +1 -0
  9. data/spec/dummy/app/models/sequenced_item.rb +1 -1
  10. data/spec/dummy/app/views/items/index.html.erb +2 -2
  11. data/spec/dummy/app/views/sequenced_items/index.html.erb +2 -2
  12. data/spec/dummy/config/application.rb +2 -0
  13. data/spec/dummy/db/development.sqlite3 +0 -0
  14. data/spec/dummy/db/migrate/20131223124841_create_items.rb +1 -1
  15. data/spec/dummy/db/migrate/20170414031946_create_sequenced_items.rb +1 -1
  16. data/spec/dummy/db/schema.rb +0 -1
  17. data/spec/dummy/db/test.sqlite3 +0 -0
  18. data/spec/dummy/log/development.log +686 -0
  19. data/spec/dummy/log/test.log +7647 -0
  20. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-M/-MwqdQ791aPntbEy7upqu3cADI-2KlCz2SjOQXwCd5w.cache +0 -0
  21. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/0l/0lxOLKgMUMzAFvW2sDd-e6N0cnDR_PNDv-s69MSMiAA.cache +0 -0
  22. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/1U/1U1pW6Uavmef847C1JXIdugGlbThpoaH5psPBv7R_J8.cache +1 -0
  23. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/31/31pAh-ykal9wFBvxGXPlw8TvfVP9I3g8AKUN1RD12Sg.cache +1 -0
  24. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5_/5_YaqD4YPAqkrxzucbFB0d7IJcA1OkWUzybswbWefwc.cache +0 -0
  25. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/77/776QkbrTcZYapIcbwGFTJtbgfh3cNgMT2c40Aj54fEU.cache +0 -0
  26. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/7U/7UBkdE46evReoZt_EYaKUwH58UyqcXz2y56G9dIqFP0.cache +1 -0
  27. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8f/8fIg59WLGyiXkq1RifIbIftwSQZKF-yZ2EXsZMXMch8.cache +0 -0
  28. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/9U/9U2DhKS6xwVOdGrAQv2FhUnh6toPdgGRab6NIRsXp0o.cache +0 -0
  29. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ag/AgpGgXbfyusDXjo1mDj-AFk_o2SSeoZO0lEdU9qWQX8.cache +0 -0
  30. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Bq/BqBJyBS41Jda6NbagWARTtmiCR-quplnsjL7d5z4p1c.cache +0 -0
  31. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Bq/bqKThELB3qgSQcjs5dN-vSX3A407npeY8MIKpowe-Js.cache +0 -0
  32. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/C8/C8hb35kAhvJiAFUsoqojTrsfrThtdp49E4nptXI_9Ro.cache +1 -0
  33. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/CO/COP5g_SpHcHL9NYeZARiQDwPnIZty47_OGxvjAnrncI.cache +1 -0
  34. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Dm/DmmfrCpXtt74Hr6NO54lxyOCDv6klnDyBqeDFR7oDU8.cache +0 -0
  35. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Dm/dmwAuKE4eBzCm6glINJ_ZwcD69v9t8l15j03VzHLxh8.cache +0 -0
  36. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/E6/E6CVif4RjoY04O2IF5Vb4QI-F_S02jIpChkH6YLZy9A.cache +1 -0
  37. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ei/Eiu0Y5dKtNlRmNbmh7sA6xxf5BCI-ijBOXcJG5XDPAQ.cache +1 -0
  38. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Gn/GnyjUg0eyY4eXLM8LB7BH4Ivh2xVIcwH_qv7mwyyjJw.cache +0 -0
  39. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/HF/HFuNhzNZA5ILxIzWi2wxnZ_uEYPrAQ4OVoo0Y_92muU.cache +0 -0
  40. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Jc/JcODu6JBZielcrLviF0o_T1GbgKIhK-zRaK6x6QTozw.cache +1 -0
  41. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Jn/JnjBvfKtl8TXKycLjUNrFw0bedaarjPKagB7vF8TUK8.cache +1 -0
  42. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ND/NDJu7JZ4s949_mBSyh1RlDbvIA4g5-5pvgaOWqG-Ac0.cache +1 -0
  43. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/NW/NWqf7xq8uxCcCLqLyqR4P6Xdp7ptpiR-nfnIdZpLUKM.cache +0 -0
  44. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/OX/OXQFRQZ5OA2i3YtnP1fZ96aWeUC3_IIqO4fAMdR9FsM.cache +0 -0
  45. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Oq/Oq9qxOybVTkEsplZxHkAXQtRjPsCla5NvnuEBpzA6aQ.cache +1 -0
  46. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Qn/QnVahtlgxWDe8pZzWsgQMPKPFKUVrX-zODRgJ88d8g0.cache +1 -0
  47. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/R6/R6jjGP-ss5qq0jCtD8DVMldYO5CZ3CnR8ATE0bBwS9s.cache +0 -0
  48. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/RT/RtNDq2dTGBn8a9lKsp_NdLkLSZ_qC14uMcRAnJa8MwU.cache +1 -0
  49. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/SE/SEOXTAR9ayZjI7koj_F8NhHi0BcVNcfS2CJoYYvgfmA.cache +0 -0
  50. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/UG/UGUKHaW4DiFx1aZgMUpclbzKInIDVBd5f75rfkqDRd4.cache +0 -0
  51. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Vi/VinvgmlVKmvmmSv0n3iGxgjUEMX6B95Jsp7rUJkKvxk.cache +0 -0
  52. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/YC/YCmSRb5SEvvoBvnJsRlYJpjX4bDwV_X9TkGytX3NnRs.cache +1 -0
  53. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Yu/yue8-Q5bNZaBmyxqsXfEfa-f2AFyNQfYiPjFz1iiOC8.cache +1 -0
  54. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Z9/Z9BQI9WcvV299qzaK1M_BzYQ0JyoibxRUHVkgjQAglI.cache +0 -0
  55. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ZJ/ZJ44p6_pZuT7WpBrGCBRBtJ5QdfNcMjNQvu5qqXgxDk.cache +1 -0
  56. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aN/aN7HmMd7uTy_8MNbMlPVBrUnBks5bEWJMA6PBRz6bHs.cache +1 -0
  57. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/by/bycyWG1KvMAFy-MNbyR0Jg_fDRj_lPz1FTGz-a3lBuw.cache +0 -0
  58. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/d2/d2Yn085-A4NAn9xG1tVfpAF_Wq_xF-41XbpMJWJrx3I.cache +0 -0
  59. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ep/epOwUzkCBUUf3qec0T3hdrf2NnOzeQ6raN7_mH70hIE.cache +1 -0
  60. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/fO/Fot3cRKzEJDZ24jtzhnIGTxk4y0oangfskCEIQhU5mM.cache +0 -0
  61. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/fR/fR7lphpj83NQV2tYMU8ejAZ8IE9LVsOaLLjXr3QB0hY.cache +0 -0
  62. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gP/gPOrGelZGMmC2JmWhxBVOrc1sFhQtfgSnODI-Ul_sWs.cache +1 -0
  63. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hj/Hj4c2gR3CanPccvkZw0kp49U1R-mtB9wIGo7YzEUtRY.cache +0 -0
  64. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/l-/l-tlnwp5uJdRwxd_83TYgEcK2tKtc0BgtknMUirnIMU.cache +0 -0
  65. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/lv/lvVdgHzQTW7MQ3US3THd4ZE84XRfWcPT5qwJLXv0rN4.cache +1 -0
  66. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/m2/m2egBUvfxGWpUmYKTgZQuNXHWm8EvHntYVaIlpLM38s.cache +0 -0
  67. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/nh/nh8v3yrwWXGoRhmmkfOR5UPo9GMZPUFyt6LSRdvHyy8.cache +0 -0
  68. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/o4/o4Y9F2XU_uVXmdHbLHiTSqN0NE0piayqn2EwMN4yDgQ.cache +0 -0
  69. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/oE/OEkPR9rCjDF_RsHHp1mxYgYBdzX3EWkvcck8pAa7-cI.cache +0 -0
  70. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/oJ/oJCqbKqh-ra1_jrvq68KLQTNjUH6bSq5jguVUig8lcE.cache +0 -0
  71. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pf/pfqGxtUxd_Aih4aBeO5sUUDN0-3Vb0S5_nqLjj0cMAw.cache +1 -0
  72. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/q6/q6BYa32YJF11eGVapO4ouNl6gayPIsARgMavlzZmoi0.cache +0 -0
  73. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/s7/s7VWT9DZLFqtya2VSPGzhMBSY277k6KTrT8nUYpeBu8.cache +0 -0
  74. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/uV/uV_S1Cg7y0O0HsF1rc8eYpK_AgSbsKuL5jH9NMfjv04.cache +0 -0
  75. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/up/upVymLTBG2KFDubvLigJERLKkH6kU_CVWmn2lgOYg54.cache +0 -0
  76. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/uw/uWpRXEIJzFMcsSUwp-Vu5QLS3vWbos65wsNMgWi-9k0.cache +0 -0
  77. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/vn/vnFhMxGWzyZFIqsnCGE3pR5PnSiBGsLvdsOfQccjeZ4.cache +1 -0
  78. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/wv/wvLIhRJ2wqhPrnqvkacm2QHyG0rFmmf3VSAGNiZnOWU.cache +0 -0
  79. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/x7/x7KkTV3ibfIEysLB_ug5bfmnn2VLV_BldukPR3EoPBk.cache +0 -0
  80. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xb/xbyHnHRcdnYQamtz02quX36a2_ef91bDpDlDcKN9k8w.cache +0 -0
  81. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xo/xomBLC8CXZdVx5BbdIwBVW9ROU-L7Lx6udDAW3t43I4.cache +0 -0
  82. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xo/xox6GSP3_45BgwDA_Qsm5x9I4tMzd_-JBiArTeUVQQI.cache +0 -0
  83. data/spec/helpers/sortable_helper_spec.rb +1 -1
  84. data/spec/models/rails_sortable/model_spec.rb +13 -3
  85. data/spec/spec_helper.rb +0 -1
  86. metadata +93 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f71d0f09c228e23feab8feb87bdfb86ef381ab87
4
- data.tar.gz: 60cb4a0ac744d60116e3315b7ed2f443d995bd62
3
+ metadata.gz: f87ea45db075e7775fe975f17a4efba046cc6390
4
+ data.tar.gz: 3e363558e6544afadf50af11e3f327d196db5b7b
5
5
  SHA512:
6
- metadata.gz: 51c26d72c68ecda96ef5f4100f7b809404d1eb95b61467b556155e8742040c5e4d611a039676b9c744d46b5a82c7bb328e24990369fcb8368f93c72e55993839
7
- data.tar.gz: bb71c5d7176570a81c7f91e4ad886fb3e025a3b456ad75bef7b22268f2cbc4ec1a5702d2945e8b52c033ed16a78c33bd02db532690d3a4203a1577c9af515bc8
6
+ metadata.gz: fa5ae363dfd93a2bf1d28f9f9e4808a10b3dcb00e51efa37daa73c5c14603aa3086ca46af130648c59a318ce7b7bb7a0dc2dcd0b0c5bf18182a309497ed7a7f6
7
+ data.tar.gz: 527606581cafb9e132d87419bf146a0aad09b232daaa6c21c6675f16074bcb3a83480914a93f418d5d140b63a7f04b79e0eb2f6c895ff9ba378ffc70e8350ddb
data/README.md CHANGED
@@ -1,31 +1,35 @@
1
1
  # RailsSortable
2
+ [![Build Status](https://travis-ci.org/itmammoth/rails_sortable.svg?branch=use_travis_ci)](https://travis-ci.org/itmammoth/rails_sortable)
2
3
 
3
- RailsSortable is a simple Rails gem that allows you to create a listing view with drag & drop sorting.
4
+ RailsSortable is a simple Rails gem that allows you to create a listing view with drag & drop sorting. The arranged order will be persisted in the table without any pain.
4
5
 
5
6
  ![RailsSortable](https://raw.githubusercontent.com/itmammoth/rails_sortable/master/rails_sortable.gif "RailsSortable")
6
7
 
7
- ## Setup
8
+ # Setup
8
9
 
9
- Add it to your Gemfile then run bundle to install it.
10
+ Add the following to your `Gemfile` then run bundle to install them.
10
11
  ```
12
+ gem 'jquery-rails'
11
13
  gem 'jquery-ui-rails'
12
14
  gem 'rails_sortable'
13
15
  ```
14
16
 
15
- And then add it to the Asset Pipeline in the application.js file:
17
+ And then add the following to the asset pipeline in the `application.js`:
16
18
  ```
19
+ //= require jquery
20
+ //= require jquery_ujs
17
21
  //= require jquery-ui/widgets/sortable
18
22
  //= require rails_sortable
19
23
  ```
20
24
 
21
- ## Usage
25
+ # Usage
22
26
 
23
- RailsSortable requires specific column on ActiveRecord Model for own implementation.
27
+ RailsSortable requires a specific column on the ActiveRecord Model for its implementation.
24
28
 
25
- For instance, the following migration indicates the case that you are attemtting to make Item model sortable.
29
+ For instance, the following migration indicates the case that you are attemtting to make `Item` model sortable.
26
30
 
27
31
  ```ruby
28
- class CreateItems < ActiveRecord::Migration
32
+ class CreateItems < ActiveRecord::Migration[5.1]
29
33
  def change
30
34
  create_table :items do |t|
31
35
  t.string :title
@@ -36,22 +40,31 @@ class CreateItems < ActiveRecord::Migration
36
40
  end
37
41
  end
38
42
  ```
39
- and Item model is
43
+ and `Item` model as
40
44
  ```ruby
41
- class Item < ActiveRecord::Base
45
+ class Item < ApplicationRecord
42
46
  include RailsSortable::Model
43
- set_sortable :sort # indicate sort column
44
- # If you don't want timestamps to be updated with sorting, use following option.
45
- # set_sortable :sort, silence_recording_timestamps: true
47
+ set_sortable :sort # Indicate a sort column
48
+ # If you do NOT want timestamps to be updated on sorting, use the following option.
49
+ # set_sortable :sort, without_updating_timestamps: true
50
+ end
51
+ ```
52
+ and `ItemsController` as
53
+ ```ruby
54
+ class ItemsController < ApplicationController
55
+ def index
56
+ @items = Item.order(:sort).all
57
+ end
46
58
  end
47
59
  ```
48
60
 
49
- and its listing view (typically - index.html.erb) is
61
+ and the listing view (typically - index.html.erb) as
50
62
  ```erb
51
63
  ...
52
- <tbody class="sortable"> <!-- sortable target -->
53
- <% sortable_fetch(@items) do |item, id_tag| %> <!-- RailsSortable helper -->
54
- <tr id="<%= id_tag %>"> <!-- you must write it -->
64
+ <table>
65
+ <tbody class="sortable"> <!-- sortable target -->
66
+ <% @items.each_with_sortable_id do |item, sortable_id| %>
67
+ <tr id="<%= sortable_id %>"> <!-- Needs id tag on sorting elements -->
55
68
  <td><%= item.title %></td>
56
69
  <td><%= item.sort %></td>
57
70
  <td><%= link_to 'Show', item %></td>
@@ -64,14 +77,38 @@ and its listing view (typically - index.html.erb) is
64
77
  ...
65
78
  ```
66
79
 
67
- finally, you apply sortable with Javascript.
80
+ finally, apply sortable with Javascript.
81
+
82
+ ```javascript
83
+ $(function() {
84
+ $('.sortable').railsSortable();
85
+ });
86
+ ```
87
+
88
+ # Javascript options
89
+ jQuery plugin `railsSortable` is just a wrapper of `jquery.ui.sortable`. therefore it accepts all of `sortbale` options.
90
+
91
+ see the [http://api.jqueryui.com/sortable/](http://api.jqueryui.com/sortable/) to get the details.
92
+
93
+ # Contribution
94
+
95
+ Fork it, then install required gems like below.
96
+ ```bash
97
+ $ bundle install --path=vender/bundle
98
+ $ appraisal install
99
+ ```
100
+
101
+ Please give me a PR freely.
102
+
103
+ ### Testing
104
+ ```bash
105
+ # Run server with rails 5.1 (rails42 & rails50 are also available)
106
+ $ appraisal rails51 spec/dummy/bin/rails s
68
107
 
69
- ```coffeescript
70
- jQuery ->
71
- $(".sortable").railsSortable()
108
+ # Run rspec for all rails versions
109
+ $ appraisal rspec
72
110
  ```
73
111
 
74
- ## Javascript options
75
- jquery plugin `railsSortable` is just a wrapper `jquery.ui.sortable`. therefore it accepts all of `sortbale` options.
112
+ # Licence
76
113
 
77
- see the [http://api.jqueryui.com/sortable/](http://api.jqueryui.com/sortable/) to get detail.
114
+ MIT Licence.
@@ -1,9 +1,7 @@
1
1
  module SortableHelper
2
-
3
2
  def sortable_fetch(models, &block)
4
- raise "You must call with block!" unless block_given?
5
- models.each do |object|
6
- yield object, "#{object.class}_#{object.id}"
7
- end
3
+ warn "[DEPRECATION] `sortable_fetch` is deprecated. Please use Enumerable#each_with_sortable_id instead."
4
+ raise "Must be called with block!" unless block_given?
5
+ models.each_with_sortable_id(&block)
8
6
  end
9
- end
7
+ end
@@ -6,7 +6,7 @@ module RailsSortable
6
6
  # ex)
7
7
  # class SampleModel < ActiveRecord::Base
8
8
  # include RailsSortable::Model
9
- # set_sortable :sort, silence_recording_timestamps: true
9
+ # set_sortable :sort, without_updating_timestamps: true
10
10
  # end
11
11
  #
12
12
  module Model
@@ -20,7 +20,10 @@ module RailsSortable
20
20
  def update_sort!(new_value)
21
21
  write_attribute sort_attribute, new_value
22
22
  if self.class.sortable_options[:silence_recording_timestamps]
23
- silence_recording_timestamps { save! }
23
+ warn "[DEPRECATION] `silence_recording_timestamps` is deprecated. Please use `without_updating_timestamps` instead."
24
+ without_updating_timestamps { save! }
25
+ elsif self.class.sortable_options[:without_updating_timestamps]
26
+ without_updating_timestamps { save! }
24
27
  else
25
28
  save!
26
29
  end
@@ -33,7 +36,7 @@ module RailsSortable
33
36
  write_attribute sort_attribute, max_sort
34
37
  end
35
38
 
36
- def silence_recording_timestamps
39
+ def without_updating_timestamps
37
40
  raise ArgumentError unless block_given?
38
41
  original_record_timestamps = self.class.record_timestamps
39
42
  self.class.record_timestamps = false
@@ -52,8 +55,8 @@ module RailsSortable
52
55
  module ClassMethods
53
56
  #
54
57
  # allowed options
55
- # - silence_recording_timestamps
56
- # When it is true, timestamp(updated_at) will be NOT modified with reordering.
58
+ # - without_updating_timestamps
59
+ # When it is true, timestamp(updated_at) will be NOT touched on reordering.
57
60
  #
58
61
  def set_sortable(attribute, options = {})
59
62
  self.define_singleton_method(:sort_attribute) { attribute }
@@ -0,0 +1,6 @@
1
+ module Enumerable
2
+ def each_with_sortable_id(&block)
3
+ raise "Must be called with block!" unless block_given?
4
+ each { |e| yield e, "#{e.class}_#{e.id}" }
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ Dir.glob(File.expand_path('core_ext/*.rb', File.dirname(__FILE__))).each do |path|
2
+ require path
3
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsSortable
2
- VERSION = "0.1.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require "rails_sortable/engine"
2
+ require "rails_sortable/core_ext"
2
3
 
3
4
  module RailsSortable
4
5
  end
@@ -1,6 +1,6 @@
1
1
  class SequencedItem < ActiveRecord::Base
2
2
  include RailsSortable::Model
3
- set_sortable :sequence, silence_recording_timestamps: true
3
+ set_sortable :sequence, without_updating_timestamps: true
4
4
 
5
5
  default_scope -> { order(:sequence) }
6
6
  end
@@ -13,8 +13,8 @@
13
13
  </thead>
14
14
 
15
15
  <tbody class="sortable">
16
- <% sortable_fetch(@items) do |item, id_tag| %>
17
- <tr id="<%= id_tag %>">
16
+ <% @items.each_with_sortable_id do |item, sortable_id| %>
17
+ <tr id="<%= sortable_id %>">
18
18
  <td><%= item.title %></td>
19
19
  <td><%= item.sort %></td>
20
20
  <td><%= item.updated_at %></td>
@@ -13,8 +13,8 @@
13
13
  </thead>
14
14
 
15
15
  <tbody class="sortable">
16
- <% sortable_fetch(@sequenced_items) do |sequenced_item, id_tag| %>
17
- <tr id="<%= id_tag %>">
16
+ <% @sequenced_items.each_with_sortable_id do |sequenced_item, sortable_id| %>
17
+ <tr id="<%= sortable_id %>">
18
18
  <td><%= sequenced_item.title %></td>
19
19
  <td><%= sequenced_item.sequence %></td>
20
20
  <td><%= sequenced_item.updated_at %></td>
@@ -24,5 +24,7 @@ module Dummy
24
24
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
25
25
  # config.i18n.default_locale = :de
26
26
  end
27
+
28
+ MigrationClass = Gem::Version.new(Rails.version) < Gem::Version.new(5) ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
27
29
  end
28
30
 
Binary file
@@ -1,4 +1,4 @@
1
- class CreateItems < ActiveRecord::Migration
1
+ class CreateItems < Dummy::MigrationClass
2
2
  def change
3
3
  create_table :items do |t|
4
4
  t.string :title
@@ -1,4 +1,4 @@
1
- class CreateSequencedItems < ActiveRecord::Migration
1
+ class CreateSequencedItems < Dummy::MigrationClass
2
2
  def change
3
3
  create_table :sequenced_items do |t|
4
4
  t.string :title
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  # This file is auto-generated from the current state of the database. Instead
3
2
  # of editing this file, please use the migrations feature of Active Record to
4
3
  # incrementally modify your database, and then regenerate this schema definition.
Binary file