rails_sortable 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +20 -0
- data/README.md +3 -0
- data/Rakefile +23 -0
- data/app/controllers/sortable_controller.rb +22 -0
- data/app/helpers/sortable_helper.rb +9 -0
- data/config/routes.rb +3 -0
- data/lib/rails_sortable.rb +4 -0
- data/lib/rails_sortable/engine.rb +4 -0
- data/lib/rails_sortable/version.rb +3 -0
- data/lib/tasks/rails_sortable_tasks.rake +4 -0
- data/spec/controllers/sortable_controller_spec.rb +18 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +17 -0
- data/spec/dummy/app/assets/javascripts/items.js +5 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/assets/stylesheets/items.css +4 -0
- data/spec/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/items_controller.rb +58 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/helpers/items_helper.rb +2 -0
- data/spec/dummy/app/models/item.rb +3 -0
- data/spec/dummy/app/views/items/_form.html.erb +25 -0
- data/spec/dummy/app/views/items/edit.html.erb +6 -0
- data/spec/dummy/app/views/items/index.html.erb +29 -0
- data/spec/dummy/app/views/items/new.html.erb +5 -0
- data/spec/dummy/app/views/items/show.html.erb +14 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +28 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20131223124841_create_items.rb +10 -0
- data/spec/dummy/db/schema.rb +23 -0
- data/spec/dummy/db/seeds.rb +1 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +4188 -0
- data/spec/dummy/log/test.log +269 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/09c0e9561d4e4c3ec8867c7a8a9b9b42 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0e84bdca51a3a0487e386e9da49cab86 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/12552dd68c1fdaa0e003f5139c1ef188 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/21445b043a030a6b874e6fc2926b3f03 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/24af22f97404b0fdf1924aa9c64dbefc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/24e4e999e945d87db51a6c0639266e6c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/271346ac3b88c8d5b342e1e9617ecd25 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2a668655870d5f03dc3a3d9aa691bfed +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3d7976736cb0fb316656b1ceeeb68979 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3f88dd8cc7343b35f4ad7016c8a8aa2f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/443eeec33985f295f3de84d801267f43 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/45690638871d819932026564912e2195 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/46bfe8e4c6de42d38202670518db2720 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/47210cd74cee569fb21f67fe042804a0 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/48711599d95075043d13736e542084b4 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/59a3fa5688c2134fd84019b59936c2b6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5c5e9ad9739439966aa96de5924073ba +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5da49418ee5d9d42e17ac02fca5457b6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/618391a0ef7663854d9df6f34286bfbd +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/62485efd0b3ff6bb41eac572b53368da +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/70de4d1e613727407438e972a9099dfd +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/71418eee6104b64017eb6e6a1f2773c4 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/72ac123f6449bd8bef14d2eab5098f14 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7c69465efeecee1a50197180d6684639 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7c7385263be91392fe4b3ebac4e30c18 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/87d94fb98d5bd32dfd9d145e5b837a83 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8f32d9d0ad1e7bbeaf8ae8477dc9f861 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/96d9c878cbed31839fb895da7fea6146 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/9daa91d8364698dd61c25d6de342962d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a1a1917817d5eb7f6a00422e9b3f731e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b0e2031acc600ce5786fd4e5685545ae +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/bc6acc8a7c1dacadb37b0bd2e5df09dd +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c292a12f53708efd19a07da3aa15a0b8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c374e273ada03bedc3ec10dddbaf5a5d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c5b2447c005428e7f762f972217f7fc9 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c7fb08920199d3630a32e2233c85433e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cb36d45bba6ca52ebb343d2ceeff7645 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ccaade7f71ba3ee748987ed0d4e09af8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d23f84be9419f8cd6361e094fd9aa0ff +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d2b64ac41957bdfd9906972476b82d0e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d486933f2537d00d15fd3cf43bf7af8f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d4d4f33a44b8bd5e03a00ac263ac59d8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d69e40330afbc5a33c238ac4dfbd86a6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/df136c2e2fc74151ed1324d5fd05481e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e84cf0ef44a46fdbcc61114872eb0714 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e9bb2f00040ed550d231427ad03b236e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ecbc5574068be4c5270f875b71d7e95a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ee8d3ea7f4ea5f4f5204e13648ebad08 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f5086810e52de33164c7427bec325b8d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f932895e1a3359b877edea2bedae3850 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ff209c6e804d4f56d185430b6ed27bc4 +0 -0
- data/spec/helpers/enumerable_spec.rb +25 -0
- data/spec/spec_helper.rb +42 -0
- data/vendor/assets/javascripts/rails_sortable.js +17 -0
- metadata +321 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f13ddffad1bcb7f75baed5b37eb2c78695fabc4f
|
4
|
+
data.tar.gz: aa42e1a7f5c572f0b8c64e8daae28516d594b10d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 80575f28a70f3e46b8dd1ed58c66ada88feb52841388fa2d7ffffd6d890400c25e557caeb36d6a8d7ca59df823c1ac7e2cdcbdeb494f817e3f307ad1feb1f8bc
|
7
|
+
data.tar.gz: ab4bb864faafe0f3352d846cf9df7e8bcd909be3980247fa3a8668e6ae5428ee5160f3891f9de69c37e7804a2703682837622c0adb5ba92b9019d89a4c18aea8
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 itmammoth
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'RailsSortable'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class SortableController < ApplicationController
|
2
|
+
#
|
3
|
+
# post /sortable/reorder, :klass => ["1", "3", "2"]
|
4
|
+
#
|
5
|
+
def reorder
|
6
|
+
klass, ids = parse_params
|
7
|
+
models = klass.order(:sort).to_a
|
8
|
+
ids.each_with_index do |id, new_sort|
|
9
|
+
model = models.find {|m| m.id == id }
|
10
|
+
model.update_attributes! sort: new_sort if model.sort != new_sort
|
11
|
+
end
|
12
|
+
render nothing: true
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def parse_params
|
18
|
+
klass_name = params.keys.first
|
19
|
+
ids = params[klass_name].map {|id| id.to_i }
|
20
|
+
[ klass_name.constantize, ids ]
|
21
|
+
end
|
22
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SortableController do
|
4
|
+
describe "POST reorder" do
|
5
|
+
before do
|
6
|
+
@item1 = Item.create! sort: 0
|
7
|
+
@item2 = Item.create! sort: 1
|
8
|
+
@item3 = Item.create! sort: 2
|
9
|
+
end
|
10
|
+
it "should reorder models" do
|
11
|
+
post :reorder, Item: [@item1.id, @item3.id, @item2.id]
|
12
|
+
expect(response.body).to be_blank
|
13
|
+
expect(Item.find(@item1.id).sort).to eql 0
|
14
|
+
expect(Item.find(@item2.id).sort).to eql 2
|
15
|
+
expect(Item.find(@item3.id).sort).to eql 1
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require jquery.ui.sortable
|
16
|
+
//= require rails_sortable
|
17
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,56 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:visited { color: #666; }
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
18
|
+
|
19
|
+
div.field, div.actions {
|
20
|
+
margin-bottom: 10px;
|
21
|
+
}
|
22
|
+
|
23
|
+
#notice {
|
24
|
+
color: green;
|
25
|
+
}
|
26
|
+
|
27
|
+
.field_with_errors {
|
28
|
+
padding: 2px;
|
29
|
+
background-color: red;
|
30
|
+
display: table;
|
31
|
+
}
|
32
|
+
|
33
|
+
#error_explanation {
|
34
|
+
width: 450px;
|
35
|
+
border: 2px solid red;
|
36
|
+
padding: 7px;
|
37
|
+
padding-bottom: 0;
|
38
|
+
margin-bottom: 20px;
|
39
|
+
background-color: #f0f0f0;
|
40
|
+
}
|
41
|
+
|
42
|
+
#error_explanation h2 {
|
43
|
+
text-align: left;
|
44
|
+
font-weight: bold;
|
45
|
+
padding: 5px 5px 5px 15px;
|
46
|
+
font-size: 12px;
|
47
|
+
margin: -7px;
|
48
|
+
margin-bottom: 0px;
|
49
|
+
background-color: #c00;
|
50
|
+
color: #fff;
|
51
|
+
}
|
52
|
+
|
53
|
+
#error_explanation ul li {
|
54
|
+
font-size: 12px;
|
55
|
+
list-style: square;
|
56
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
class ItemsController < ApplicationController
|
2
|
+
before_action :set_item, only: [:show, :edit, :update, :destroy]
|
3
|
+
|
4
|
+
# GET /items
|
5
|
+
def index
|
6
|
+
@items = Item.all
|
7
|
+
end
|
8
|
+
|
9
|
+
# GET /items/1
|
10
|
+
def show
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /items/new
|
14
|
+
def new
|
15
|
+
@item = Item.new
|
16
|
+
end
|
17
|
+
|
18
|
+
# GET /items/1/edit
|
19
|
+
def edit
|
20
|
+
end
|
21
|
+
|
22
|
+
# POST /items
|
23
|
+
def create
|
24
|
+
@item = Item.new(item_params)
|
25
|
+
|
26
|
+
if @item.save
|
27
|
+
redirect_to @item, notice: 'Item was successfully created.'
|
28
|
+
else
|
29
|
+
render action: 'new'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# PATCH/PUT /items/1
|
34
|
+
def update
|
35
|
+
if @item.update(item_params)
|
36
|
+
redirect_to @item, notice: 'Item was successfully updated.'
|
37
|
+
else
|
38
|
+
render action: 'edit'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# DELETE /items/1
|
43
|
+
def destroy
|
44
|
+
@item.destroy
|
45
|
+
redirect_to items_url, notice: 'Item was successfully destroyed.'
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
# Use callbacks to share common setup or constraints between actions.
|
50
|
+
def set_item
|
51
|
+
@item = Item.find(params[:id])
|
52
|
+
end
|
53
|
+
|
54
|
+
# Only allow a trusted parameter "white list" through.
|
55
|
+
def item_params
|
56
|
+
params.require(:item).permit(:title, :sort)
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%= form_for(@item) do |f| %>
|
2
|
+
<% if @item.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@item.errors.count, "error") %> prohibited this item from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @item.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= f.label :title %><br>
|
16
|
+
<%= f.text_field :title %>
|
17
|
+
</div>
|
18
|
+
<div class="field">
|
19
|
+
<%= f.label :sort %><br>
|
20
|
+
<%= f.number_field :sort %>
|
21
|
+
</div>
|
22
|
+
<div class="actions">
|
23
|
+
<%= f.submit %>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<h1>Listing items</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<th>Title</th>
|
7
|
+
<th>Sort</th>
|
8
|
+
<th></th>
|
9
|
+
<th></th>
|
10
|
+
<th></th>
|
11
|
+
</tr>
|
12
|
+
</thead>
|
13
|
+
|
14
|
+
<tbody class="sortable">
|
15
|
+
<% sortable_fetch(@items) do |item, id_tag| %>
|
16
|
+
<tr id="<%= id_tag %>">
|
17
|
+
<td><%= item.title %></td>
|
18
|
+
<td><%= item.sort %></td>
|
19
|
+
<td><%= link_to 'Show', item %></td>
|
20
|
+
<td><%= link_to 'Edit', edit_item_path(item) %></td>
|
21
|
+
<td><%= link_to 'Destroy', item, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
22
|
+
</tr>
|
23
|
+
<% end %>
|
24
|
+
</tbody>
|
25
|
+
</table>
|
26
|
+
|
27
|
+
<br>
|
28
|
+
|
29
|
+
<%= link_to 'New Item', new_item_path %>
|