activerecord_sortable 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/activerecord_sortable/association_reflection.rb +1 -1
- data/lib/activerecord_sortable/collection_proxy.rb +19 -0
- data/lib/activerecord_sortable/has_many_association.rb +0 -1
- data/lib/activerecord_sortable/through_reflection.rb +16 -0
- data/lib/activerecord_sortable/version.rb +1 -1
- data/lib/activerecord_sortable.rb +2 -1
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +16 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/post.rb +7 -0
- data/spec/dummy/app/models/post_tag.rb +6 -0
- data/spec/dummy/app/models/tag.rb +6 -0
- data/spec/dummy/app/models/user.rb +7 -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/application.rb +23 -0
- data/spec/dummy/config/boot.rb +4 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +78 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -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 +4 -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 +56 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20141007145452_create_users.rb +10 -0
- data/spec/dummy/db/migrate/20141007150446_create_posts.rb +10 -0
- data/spec/dummy/db/migrate/20141007184100_add_position_to_posts.rb +13 -0
- data/spec/dummy/db/migrate/20141007184101_create_tags.rb +9 -0
- data/spec/dummy/db/migrate/20141007184102_create_post_tags.rb +10 -0
- data/spec/dummy/db/migrate/20141008135500_add_position_to_post_tags.rb +11 -0
- data/spec/dummy/db/schema.rb +51 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/log/development.log +3386 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/models/association_reflection_spec.rb +57 -0
- data/spec/models/association_relation_spec.rb +89 -0
- data/spec/models/has_many_association_spec.rb +53 -0
- data/spec/spec_helper.rb +25 -0
- metadata +109 -4
- data/lib/activerecord_sortable/association_relation.rb +0 -17
@@ -0,0 +1,13 @@
|
|
1
|
+
class AddPositionToPosts < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
add_column :posts, :position, :integer
|
5
|
+
add_column :posts, :user_position, :integer
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.down
|
9
|
+
remove_column :posts, :position
|
10
|
+
remove_column :posts, :user_position
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(version: 20141008135500) do
|
15
|
+
|
16
|
+
create_table "post_tags", force: true do |t|
|
17
|
+
t.integer "post_id"
|
18
|
+
t.integer "tag_id"
|
19
|
+
t.datetime "created_at"
|
20
|
+
t.datetime "updated_at"
|
21
|
+
t.integer "position"
|
22
|
+
end
|
23
|
+
|
24
|
+
add_index "post_tags", ["post_id"], name: "index_post_tags_on_post_id"
|
25
|
+
add_index "post_tags", ["tag_id"], name: "index_post_tags_on_tag_id"
|
26
|
+
|
27
|
+
create_table "posts", force: true do |t|
|
28
|
+
t.integer "user_id"
|
29
|
+
t.string "title"
|
30
|
+
t.datetime "created_at"
|
31
|
+
t.datetime "updated_at"
|
32
|
+
t.integer "position"
|
33
|
+
t.integer "user_position"
|
34
|
+
end
|
35
|
+
|
36
|
+
add_index "posts", ["user_id"], name: "index_posts_on_user_id"
|
37
|
+
|
38
|
+
create_table "tags", force: true do |t|
|
39
|
+
t.string "name"
|
40
|
+
t.datetime "created_at"
|
41
|
+
t.datetime "updated_at"
|
42
|
+
end
|
43
|
+
|
44
|
+
create_table "users", force: true do |t|
|
45
|
+
t.string "name"
|
46
|
+
t.integer "age"
|
47
|
+
t.datetime "created_at"
|
48
|
+
t.datetime "updated_at"
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
7
|
+
# Mayor.create(name: 'Emanuel', city: cities.first)
|