activerecord_sortable 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 613d759c2916cce58672ebb809ec631dca683e89
4
- data.tar.gz: 7be47af550dbad1df795c595bb30696c3662f0d2
3
+ metadata.gz: 5640a5dd9f693339206e48b5ab9b3a5da3f147ff
4
+ data.tar.gz: 308004a4966b8cf43fd8918461b36dda03ad75ef
5
5
  SHA512:
6
- metadata.gz: 91a3f787693635e7527af979644d2773c285a9bf986907bb7da51a713eb005c74ba7085dd041799545dabd5e6c2d5a77a3302b2e096e4b20182a9013d0859e78
7
- data.tar.gz: 337d2017ddcfd2574820a21a7fa9207378be3c6a8043d8e74b3726db996367ad43ef0161fb0b26a20bda382f8569c4851662c9e6673f6dddb1d39d1f31807195
6
+ metadata.gz: 29d9883a543f1e643b1fa44f2631afd345f4d38a648180432b1fd6ac914c6c93c67b262e090935a063acfe6a451523b95d07e146161e9a3b7ed3fb9bf8ddf1a4
7
+ data.tar.gz: 50e11bb35d513717b964f06a4496f06f2b4b8c12ce17f28920f50a59df4654b66083433f6d065b652f5e6b1f5316266af5d49a51ff4f4e2e98a38d01c90e8e25
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+ module ActiveRecord
3
+ class AssociationRelation
4
+
5
+ alias_method :original_to_a, :to_a
6
+
7
+ def to_a
8
+ if proxy_association.reflection.sortable? and order_values.empty?
9
+ sortable_table_name = (proxy_association.try(:through_reflection) || proxy_association.reflection).table_name
10
+ order("#{sortable_table_name}.#{proxy_association.reflection.sortable_field} ASC").to_a
11
+ else
12
+ original_to_a
13
+ end
14
+ end
15
+
16
+ end
17
+ end
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module ActiveRecordSortable
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
@@ -1,7 +1,6 @@
1
1
  require 'activerecord_sortable/association'
2
2
  require 'activerecord_sortable/association_reflection'
3
- require 'activerecord_sortable/through_reflection'
4
- require 'activerecord_sortable/collection_proxy'
3
+ require 'activerecord_sortable/association_relation'
5
4
  require 'activerecord_sortable/has_many_association'
6
5
 
7
6
  module ActiveRecordSortable
Binary file
@@ -3384,3 +3384,290 @@ Migrating to AddPositionToPostTags (20141008135500)
3384
3384
   (3.2ms) DELETE FROM "post_tags";
3385
3385
   (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3386
3386
   (0.1ms) DELETE FROM sqlite_sequence where name = 'post_tags';
3387
+  (0.1ms) begin transaction
3388
+ SQL (0.2ms) INSERT INTO "posts" ("created_at", "updated_at") VALUES (?, ?) [["created_at", "2015-09-28 12:15:37.762938"], ["updated_at", "2015-09-28 12:15:37.762938"]]
3389
+  (3.4ms) commit transaction
3390
+  (0.1ms) begin transaction
3391
+ SQL (0.1ms) INSERT INTO "tags" ("created_at", "name", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:15:37.777441"], ["name", "Tag2"], ["updated_at", "2015-09-28 12:15:37.777441"]]
3392
+  (3.4ms) commit transaction
3393
+  (0.0ms) begin transaction
3394
+ SQL (0.1ms) INSERT INTO "tags" ("created_at", "name", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:15:37.782057"], ["name", "Tag1"], ["updated_at", "2015-09-28 12:15:37.782057"]]
3395
+  (3.3ms) commit transaction
3396
+ Tag Load (0.2ms) SELECT "tags".* FROM "tags" INNER JOIN "post_tags" ON "tags"."id" = "post_tags"."tag_id" WHERE "post_tags"."post_id" = ? ORDER BY post_tags.position ASC [["post_id", 1]]
3397
+  (0.0ms) begin transaction
3398
+ SQL (0.2ms) INSERT INTO "post_tags" ("created_at", "post_id", "tag_id", "updated_at") VALUES (?, ?, ?, ?) [["created_at", "2015-09-28 12:15:37.807430"], ["post_id", 1], ["tag_id", 1], ["updated_at", "2015-09-28 12:15:37.807430"]]
3399
+ SQL (0.0ms) INSERT INTO "post_tags" ("created_at", "post_id", "tag_id", "updated_at") VALUES (?, ?, ?, ?) [["created_at", "2015-09-28 12:15:37.808816"], ["post_id", 1], ["tag_id", 2], ["updated_at", "2015-09-28 12:15:37.808816"]]
3400
+  (3.1ms) commit transaction
3401
+ PostTag Load (0.1ms) SELECT "post_tags".* FROM "post_tags" WHERE "post_tags"."post_id" = ? [["post_id", 1]]
3402
+  (0.0ms) begin transaction
3403
+ SQL (0.1ms) UPDATE "post_tags" SET "created_at" = ?, "position" = ?, "updated_at" = ? WHERE "post_tags"."id" = 1 [["created_at", "2015-09-28 12:15:37.807430"], ["position", 1], ["updated_at", "2015-09-28 12:15:37.807430"]]
3404
+  (3.3ms) commit transaction
3405
+  (0.0ms) begin transaction
3406
+ SQL (0.1ms) UPDATE "post_tags" SET "created_at" = ?, "position" = ?, "updated_at" = ? WHERE "post_tags"."id" = 2 [["created_at", "2015-09-28 12:15:37.808816"], ["position", 2], ["updated_at", "2015-09-28 12:15:37.808816"]]
3407
+  (3.3ms) commit transaction
3408
+  (0.0ms) begin transaction
3409
+  (0.0ms) commit transaction
3410
+ PostTag Load (0.1ms) SELECT "post_tags".* FROM "post_tags" WHERE "post_tags"."post_id" = 1 AND "post_tags"."tag_id" = 1 LIMIT 1
3411
+  (3.0ms) DELETE FROM "users";
3412
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3413
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'users';
3414
+  (2.9ms) DELETE FROM "posts";
3415
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3416
+  (3.1ms) DELETE FROM sqlite_sequence where name = 'posts';
3417
+  (3.7ms) DELETE FROM "tags";
3418
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3419
+  (3.8ms) DELETE FROM sqlite_sequence where name = 'tags';
3420
+  (3.8ms) DELETE FROM "post_tags";
3421
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3422
+  (3.7ms) DELETE FROM sqlite_sequence where name = 'post_tags';
3423
+  (0.0ms) begin transaction
3424
+ SQL (0.1ms) INSERT INTO "users" ("created_at", "updated_at") VALUES (?, ?) [["created_at", "2015-09-28 12:15:37.858512"], ["updated_at", "2015-09-28 12:15:37.858512"]]
3425
+  (3.9ms) commit transaction
3426
+  (0.0ms) begin transaction
3427
+ SQL (0.2ms) INSERT INTO "posts" ("created_at", "title", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:15:37.865953"], ["title", "Post2"], ["updated_at", "2015-09-28 12:15:37.865953"]]
3428
+  (3.4ms) commit transaction
3429
+  (0.0ms) begin transaction
3430
+ SQL (0.1ms) INSERT INTO "posts" ("created_at", "title", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:15:37.870571"], ["title", "Post1"], ["updated_at", "2015-09-28 12:15:37.870571"]]
3431
+  (2.9ms) commit transaction
3432
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = ? ORDER BY posts.position ASC [["user_id", 1]]
3433
+  (0.1ms) begin transaction
3434
+ SQL (0.2ms) UPDATE "posts" SET "updated_at" = ?, "user_id" = ? WHERE "posts"."id" = 1 [["updated_at", "2015-09-28 12:15:37.876819"], ["user_id", 1]]
3435
+ SQL (0.2ms) UPDATE "posts" SET "updated_at" = ?, "user_id" = ? WHERE "posts"."id" = 2 [["updated_at", "2015-09-28 12:15:37.878078"], ["user_id", 1]]
3436
+  (3.6ms) commit transaction
3437
+  (0.1ms) begin transaction
3438
+ SQL (0.4ms) UPDATE "posts" SET "position" = ?, "updated_at" = ? WHERE "posts"."id" = 1 [["position", 1], ["updated_at", "2015-09-28 12:15:37.883549"]]
3439
+  (3.1ms) commit transaction
3440
+  (0.1ms) begin transaction
3441
+ SQL (0.4ms) UPDATE "posts" SET "position" = ?, "updated_at" = ? WHERE "posts"."id" = 2 [["position", 2], ["updated_at", "2015-09-28 12:15:37.888803"]]
3442
+  (3.6ms) commit transaction
3443
+  (0.1ms) begin transaction
3444
+  (0.0ms) commit transaction
3445
+  (4.0ms) DELETE FROM "users";
3446
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3447
+  (3.4ms) DELETE FROM sqlite_sequence where name = 'users';
3448
+  (3.6ms) DELETE FROM "posts";
3449
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3450
+  (3.5ms) DELETE FROM sqlite_sequence where name = 'posts';
3451
+  (3.5ms) DELETE FROM "tags";
3452
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3453
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'tags';
3454
+  (2.9ms) DELETE FROM "post_tags";
3455
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3456
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'post_tags';
3457
+  (0.0ms) begin transaction
3458
+ SQL (0.1ms) INSERT INTO "tags" ("created_at", "name", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:15:37.917875"], ["name", "Tag2"], ["updated_at", "2015-09-28 12:15:37.917875"]]
3459
+  (3.4ms) commit transaction
3460
+  (0.0ms) begin transaction
3461
+ SQL (0.1ms) INSERT INTO "tags" ("created_at", "name", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:15:37.922213"], ["name", "Tag1"], ["updated_at", "2015-09-28 12:15:37.922213"]]
3462
+  (3.3ms) commit transaction
3463
+  (0.0ms) begin transaction
3464
+ SQL (0.1ms) INSERT INTO "tags" ("created_at", "name", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:15:37.926429"], ["name", "Tag3"], ["updated_at", "2015-09-28 12:15:37.926429"]]
3465
+  (3.3ms) commit transaction
3466
+  (0.1ms) begin transaction
3467
+ SQL (0.1ms) INSERT INTO "posts" ("created_at", "updated_at") VALUES (?, ?) [["created_at", "2015-09-28 12:15:37.933751"], ["updated_at", "2015-09-28 12:15:37.933751"]]
3468
+ SQL (0.1ms) INSERT INTO "post_tags" ("created_at", "position", "post_id", "tag_id", "updated_at") VALUES (?, ?, ?, ?, ?) [["created_at", "2015-09-28 12:15:37.934521"], ["position", 1], ["post_id", 1], ["tag_id", 1], ["updated_at", "2015-09-28 12:15:37.934521"]]
3469
+ SQL (0.0ms) INSERT INTO "post_tags" ("created_at", "post_id", "tag_id", "updated_at") VALUES (?, ?, ?, ?) [["created_at", "2015-09-28 12:15:37.935181"], ["post_id", 1], ["tag_id", 2], ["updated_at", "2015-09-28 12:15:37.935181"]]
3470
+ SQL (0.0ms) INSERT INTO "post_tags" ("created_at", "post_id", "tag_id", "updated_at") VALUES (?, ?, ?, ?) [["created_at", "2015-09-28 12:15:37.935762"], ["post_id", 1], ["tag_id", 3], ["updated_at", "2015-09-28 12:15:37.935762"]]
3471
+  (2.9ms) commit transaction
3472
+  (0.0ms) begin transaction
3473
+ SQL (0.1ms) UPDATE "post_tags" SET "position" = ?, "updated_at" = ? WHERE "post_tags"."id" = 2 [["position", 2], ["updated_at", "2015-09-28 12:15:37.939796"]]
3474
+  (2.8ms) commit transaction
3475
+  (0.0ms) begin transaction
3476
+ SQL (0.2ms) UPDATE "post_tags" SET "position" = ?, "updated_at" = ? WHERE "post_tags"."id" = 3 [["position", 3], ["updated_at", "2015-09-28 12:15:37.943535"]]
3477
+  (2.9ms) commit transaction
3478
+  (0.1ms) begin transaction
3479
+  (0.0ms) commit transaction
3480
+ Tag Load (0.2ms) SELECT "tags".* FROM "tags" INNER JOIN "post_tags" ON "tags"."id" = "post_tags"."tag_id" WHERE "post_tags"."post_id" = ? ORDER BY "tags"."name" ASC [["post_id", 1]]
3481
+  (5.9ms) DELETE FROM "users";
3482
+  (0.2ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3483
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'users';
3484
+  (2.6ms) DELETE FROM "posts";
3485
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3486
+  (2.9ms) DELETE FROM sqlite_sequence where name = 'posts';
3487
+  (3.4ms) DELETE FROM "tags";
3488
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3489
+  (3.4ms) DELETE FROM sqlite_sequence where name = 'tags';
3490
+  (3.6ms) DELETE FROM "post_tags";
3491
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3492
+  (3.0ms) DELETE FROM sqlite_sequence where name = 'post_tags';
3493
+  (0.0ms) begin transaction
3494
+ SQL (0.1ms) INSERT INTO "tags" ("created_at", "name", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:15:37.977356"], ["name", "Tag2"], ["updated_at", "2015-09-28 12:15:37.977356"]]
3495
+  (3.3ms) commit transaction
3496
+  (0.0ms) begin transaction
3497
+ SQL (0.1ms) INSERT INTO "tags" ("created_at", "name", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:15:37.981621"], ["name", "Tag1"], ["updated_at", "2015-09-28 12:15:37.981621"]]
3498
+  (3.3ms) commit transaction
3499
+  (0.0ms) begin transaction
3500
+ SQL (0.1ms) INSERT INTO "tags" ("created_at", "name", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:15:37.985808"], ["name", "Tag3"], ["updated_at", "2015-09-28 12:15:37.985808"]]
3501
+  (4.0ms) commit transaction
3502
+  (0.1ms) begin transaction
3503
+ SQL (0.1ms) INSERT INTO "posts" ("created_at", "updated_at") VALUES (?, ?) [["created_at", "2015-09-28 12:15:37.993789"], ["updated_at", "2015-09-28 12:15:37.993789"]]
3504
+ SQL (0.1ms) INSERT INTO "post_tags" ("created_at", "position", "post_id", "tag_id", "updated_at") VALUES (?, ?, ?, ?, ?) [["created_at", "2015-09-28 12:15:37.994662"], ["position", 1], ["post_id", 1], ["tag_id", 1], ["updated_at", "2015-09-28 12:15:37.994662"]]
3505
+ SQL (0.1ms) INSERT INTO "post_tags" ("created_at", "post_id", "tag_id", "updated_at") VALUES (?, ?, ?, ?) [["created_at", "2015-09-28 12:15:37.995443"], ["post_id", 1], ["tag_id", 2], ["updated_at", "2015-09-28 12:15:37.995443"]]
3506
+ SQL (0.1ms) INSERT INTO "post_tags" ("created_at", "post_id", "tag_id", "updated_at") VALUES (?, ?, ?, ?) [["created_at", "2015-09-28 12:15:37.996143"], ["post_id", 1], ["tag_id", 3], ["updated_at", "2015-09-28 12:15:37.996143"]]
3507
+  (3.0ms) commit transaction
3508
+  (0.0ms) begin transaction
3509
+ SQL (0.1ms) UPDATE "post_tags" SET "position" = ?, "updated_at" = ? WHERE "post_tags"."id" = 2 [["position", 2], ["updated_at", "2015-09-28 12:15:38.000575"]]
3510
+  (2.5ms) commit transaction
3511
+  (0.1ms) begin transaction
3512
+ SQL (0.1ms) UPDATE "post_tags" SET "position" = ?, "updated_at" = ? WHERE "post_tags"."id" = 3 [["position", 3], ["updated_at", "2015-09-28 12:15:38.003995"]]
3513
+  (3.0ms) commit transaction
3514
+  (0.1ms) begin transaction
3515
+  (0.1ms) commit transaction
3516
+  (3.1ms) DELETE FROM "users";
3517
+  (0.2ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3518
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'users';
3519
+  (2.7ms) DELETE FROM "posts";
3520
+  (0.3ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3521
+  (3.2ms) DELETE FROM sqlite_sequence where name = 'posts';
3522
+  (3.1ms) DELETE FROM "tags";
3523
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3524
+  (3.3ms) DELETE FROM sqlite_sequence where name = 'tags';
3525
+  (3.6ms) DELETE FROM "post_tags";
3526
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3527
+  (3.4ms) DELETE FROM sqlite_sequence where name = 'post_tags';
3528
+  (0.0ms) begin transaction
3529
+ SQL (0.1ms) INSERT INTO "posts" ("created_at", "title", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:15:38.034699"], ["title", "Post2"], ["updated_at", "2015-09-28 12:15:38.034699"]]
3530
+  (2.9ms) commit transaction
3531
+  (0.0ms) begin transaction
3532
+ SQL (0.1ms) INSERT INTO "posts" ("created_at", "title", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:15:38.038588"], ["title", "Post1"], ["updated_at", "2015-09-28 12:15:38.038588"]]
3533
+  (3.3ms) commit transaction
3534
+  (0.0ms) begin transaction
3535
+ SQL (0.1ms) INSERT INTO "posts" ("created_at", "title", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:15:38.042867"], ["title", "Post3"], ["updated_at", "2015-09-28 12:15:38.042867"]]
3536
+  (2.9ms) commit transaction
3537
+  (0.0ms) begin transaction
3538
+ SQL (0.1ms) INSERT INTO "users" ("created_at", "updated_at") VALUES (?, ?) [["created_at", "2015-09-28 12:15:38.047239"], ["updated_at", "2015-09-28 12:15:38.047239"]]
3539
+ SQL (0.1ms) UPDATE "posts" SET "position" = ?, "updated_at" = ?, "user_id" = ? WHERE "posts"."id" = 1 [["position", 1], ["updated_at", "2015-09-28 12:15:38.047873"], ["user_id", 1]]
3540
+ SQL (0.0ms) UPDATE "posts" SET "updated_at" = ?, "user_id" = ? WHERE "posts"."id" = 2 [["updated_at", "2015-09-28 12:15:38.048436"], ["user_id", 1]]
3541
+ SQL (0.1ms) UPDATE "posts" SET "updated_at" = ?, "user_id" = ? WHERE "posts"."id" = 3 [["updated_at", "2015-09-28 12:15:38.048864"], ["user_id", 1]]
3542
+  (2.9ms) commit transaction
3543
+  (0.0ms) begin transaction
3544
+ SQL (0.1ms) UPDATE "posts" SET "position" = ?, "updated_at" = ? WHERE "posts"."id" = 2 [["position", 2], ["updated_at", "2015-09-28 12:15:38.052476"]]
3545
+  (2.5ms) commit transaction
3546
+  (0.1ms) begin transaction
3547
+ SQL (0.2ms) UPDATE "posts" SET "position" = ?, "updated_at" = ? WHERE "posts"."id" = 3 [["position", 3], ["updated_at", "2015-09-28 12:15:38.055824"]]
3548
+  (3.0ms) commit transaction
3549
+  (0.1ms) begin transaction
3550
+  (0.1ms) commit transaction
3551
+ Post Load (0.3ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = ? ORDER BY "posts"."title" ASC [["user_id", 1]]
3552
+  (4.0ms) DELETE FROM "users";
3553
+  (0.2ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3554
+  (3.6ms) DELETE FROM sqlite_sequence where name = 'users';
3555
+  (3.7ms) DELETE FROM "posts";
3556
+  (0.2ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3557
+  (3.4ms) DELETE FROM sqlite_sequence where name = 'posts';
3558
+  (3.5ms) DELETE FROM "tags";
3559
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3560
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'tags';
3561
+  (3.4ms) DELETE FROM "post_tags";
3562
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3563
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'post_tags';
3564
+  (0.1ms) begin transaction
3565
+ SQL (0.2ms) INSERT INTO "posts" ("created_at", "title", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:15:38.086921"], ["title", "Post2"], ["updated_at", "2015-09-28 12:15:38.086921"]]
3566
+  (3.0ms) commit transaction
3567
+  (0.1ms) begin transaction
3568
+ SQL (0.2ms) INSERT INTO "posts" ("created_at", "title", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:15:38.091516"], ["title", "Post1"], ["updated_at", "2015-09-28 12:15:38.091516"]]
3569
+  (3.0ms) commit transaction
3570
+  (0.1ms) begin transaction
3571
+ SQL (0.2ms) INSERT INTO "posts" ("created_at", "title", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:15:38.096353"], ["title", "Post3"], ["updated_at", "2015-09-28 12:15:38.096353"]]
3572
+  (3.1ms) commit transaction
3573
+  (0.1ms) begin transaction
3574
+ SQL (0.2ms) INSERT INTO "users" ("created_at", "updated_at") VALUES (?, ?) [["created_at", "2015-09-28 12:15:38.101904"], ["updated_at", "2015-09-28 12:15:38.101904"]]
3575
+ SQL (0.1ms) UPDATE "posts" SET "position" = ?, "updated_at" = ?, "user_id" = ? WHERE "posts"."id" = 1 [["position", 1], ["updated_at", "2015-09-28 12:15:38.103120"], ["user_id", 1]]
3576
+ SQL (0.1ms) UPDATE "posts" SET "updated_at" = ?, "user_id" = ? WHERE "posts"."id" = 2 [["updated_at", "2015-09-28 12:15:38.104285"], ["user_id", 1]]
3577
+ SQL (0.1ms) UPDATE "posts" SET "updated_at" = ?, "user_id" = ? WHERE "posts"."id" = 3 [["updated_at", "2015-09-28 12:15:38.104881"], ["user_id", 1]]
3578
+  (3.7ms) commit transaction
3579
+  (0.1ms) begin transaction
3580
+ SQL (0.2ms) UPDATE "posts" SET "position" = ?, "updated_at" = ? WHERE "posts"."id" = 2 [["position", 2], ["updated_at", "2015-09-28 12:15:38.110534"]]
3581
+  (2.9ms) commit transaction
3582
+  (0.0ms) begin transaction
3583
+ SQL (0.1ms) UPDATE "posts" SET "position" = ?, "updated_at" = ? WHERE "posts"."id" = 3 [["position", 3], ["updated_at", "2015-09-28 12:15:38.114986"]]
3584
+  (2.9ms) commit transaction
3585
+  (0.0ms) begin transaction
3586
+  (0.0ms) commit transaction
3587
+  (3.0ms) DELETE FROM "users";
3588
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3589
+  (3.5ms) DELETE FROM sqlite_sequence where name = 'users';
3590
+  (3.5ms) DELETE FROM "posts";
3591
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3592
+  (3.1ms) DELETE FROM sqlite_sequence where name = 'posts';
3593
+  (2.6ms) DELETE FROM "tags";
3594
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3595
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'tags';
3596
+  (3.0ms) DELETE FROM "post_tags";
3597
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3598
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'post_tags';
3599
+  (2.9ms) DELETE FROM "users";
3600
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3601
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'users';
3602
+  (3.4ms) DELETE FROM "posts";
3603
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3604
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'posts';
3605
+  (3.4ms) DELETE FROM "tags";
3606
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3607
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'tags';
3608
+  (3.4ms) DELETE FROM "post_tags";
3609
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3610
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'post_tags';
3611
+  (3.4ms) DELETE FROM "users";
3612
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3613
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'users';
3614
+  (3.5ms) DELETE FROM "posts";
3615
+  (0.2ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3616
+  (0.2ms) DELETE FROM sqlite_sequence where name = 'posts';
3617
+  (3.7ms) DELETE FROM "tags";
3618
+  (0.2ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3619
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'tags';
3620
+  (3.5ms) DELETE FROM "post_tags";
3621
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3622
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'post_tags';
3623
+  (2.9ms) DELETE FROM "users";
3624
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3625
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'users';
3626
+  (3.6ms) DELETE FROM "posts";
3627
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3628
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'posts';
3629
+  (3.4ms) DELETE FROM "tags";
3630
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3631
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'tags';
3632
+  (3.5ms) DELETE FROM "post_tags";
3633
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3634
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'post_tags';
3635
+  (3.0ms) DELETE FROM "users";
3636
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3637
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'users';
3638
+  (3.6ms) DELETE FROM "posts";
3639
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3640
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'posts';
3641
+  (3.6ms) DELETE FROM "tags";
3642
+  (0.2ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3643
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'tags';
3644
+  (3.4ms) DELETE FROM "post_tags";
3645
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
3646
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'post_tags';
3647
+  (0.1ms) SELECT COUNT(*) FROM "posts"
3648
+  (0.2ms) begin transaction
3649
+ SQL (0.3ms) INSERT INTO "posts" ("created_at", "updated_at") VALUES (?, ?) [["created_at", "2015-09-28 12:17:56.010135"], ["updated_at", "2015-09-28 12:17:56.010135"]]
3650
+  (5.2ms) commit transaction
3651
+  (0.3ms) begin transaction
3652
+ SQL (0.6ms) INSERT INTO "tags" ("created_at", "name", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:18:10.976339"], ["name", "1"], ["updated_at", "2015-09-28 12:18:10.976339"]]
3653
+  (7.4ms) commit transaction
3654
+  (0.2ms) begin transaction
3655
+ SQL (0.5ms) INSERT INTO "tags" ("created_at", "name", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:18:21.385706"], ["name", "qwe2"], ["updated_at", "2015-09-28 12:18:21.385706"]]
3656
+  (6.7ms) commit transaction
3657
+  (0.1ms) begin transaction
3658
+ SQL (0.1ms) INSERT INTO "tags" ("created_at", "name", "updated_at") VALUES (?, ?, ?) [["created_at", "2015-09-28 12:18:31.526798"], ["name", "ewq"], ["updated_at", "2015-09-28 12:18:31.526798"]]
3659
+  (3.7ms) commit transaction
3660
+  (0.0ms) begin transaction
3661
+ SQL (0.2ms) INSERT INTO "post_tags" ("created_at", "post_id", "tag_id", "updated_at") VALUES (?, ?, ?, ?) [["created_at", "2015-09-28 12:20:04.411415"], ["post_id", 1], ["tag_id", 3], ["updated_at", "2015-09-28 12:20:04.411415"]]
3662
+  (6.2ms) commit transaction
3663
+ Tag Load (0.2ms) SELECT "tags".* FROM "tags" INNER JOIN "post_tags" ON "tags"."id" = "post_tags"."tag_id" WHERE "post_tags"."post_id" = ? ORDER BY post_tags.position ASC [["post_id", 1]]
3664
+  (0.2ms) begin transaction
3665
+ SQL (0.5ms) INSERT INTO "post_tags" ("created_at", "post_id", "tag_id", "updated_at") VALUES (?, ?, ?, ?) [["created_at", "2015-09-28 12:20:09.725375"], ["post_id", 1], ["tag_id", 1], ["updated_at", "2015-09-28 12:20:09.725375"]]
3666
+  (6.2ms) commit transaction
3667
+  (0.2ms) begin transaction
3668
+ SQL (0.5ms) INSERT INTO "post_tags" ("created_at", "post_id", "tag_id", "updated_at") VALUES (?, ?, ?, ?) [["created_at", "2015-09-28 12:20:11.392641"], ["post_id", 1], ["tag_id", 2], ["updated_at", "2015-09-28 12:20:11.392641"]]
3669
+  (6.4ms) commit transaction
3670
+  (0.2ms) begin transaction
3671
+  (0.1ms) commit transaction
3672
+ Post Load (0.3ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" DESC LIMIT 1
3673
+ Tag Load (0.2ms) SELECT "tags".* FROM "tags" INNER JOIN "post_tags" ON "tags"."id" = "post_tags"."tag_id" WHERE "post_tags"."post_id" = ? ORDER BY post_tags.position ASC [["post_id", 1]]
@@ -3,15 +3,15 @@ require 'spec_helper'
3
3
  describe 'Association reflection' do
4
4
 
5
5
  let(:post_reflection) do
6
- User.reflections['posts']
6
+ User.reflections[:posts]
7
7
  end
8
8
 
9
9
  let(:user_post_reflection) do
10
- User.reflections['user_posts']
10
+ User.reflections[:user_posts]
11
11
  end
12
12
 
13
13
  let(:sorted_post_reflection) do
14
- User.reflections['sorted_posts']
14
+ User.reflections[:sorted_posts]
15
15
  end
16
16
 
17
17
  describe '.sortable?' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_sortable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladislav Melanitskiy
@@ -14,16 +14,16 @@ dependencies:
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 4.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 4.1.0
27
27
  description: It adds possibility for sorting relation
28
28
  email:
29
29
  - co@rademade.com
@@ -34,9 +34,8 @@ files:
34
34
  - lib/activerecord_sortable.rb
35
35
  - lib/activerecord_sortable/association.rb
36
36
  - lib/activerecord_sortable/association_reflection.rb
37
- - lib/activerecord_sortable/collection_proxy.rb
37
+ - lib/activerecord_sortable/association_relation.rb
38
38
  - lib/activerecord_sortable/has_many_association.rb
39
- - lib/activerecord_sortable/through_reflection.rb
40
39
  - lib/activerecord_sortable/version.rb
41
40
  - spec/dummy/README.rdoc
42
41
  - spec/dummy/Rakefile
@@ -1,19 +0,0 @@
1
- # encoding: utf-8
2
- module ActiveRecord
3
- module Associations
4
- class CollectionProxy
5
-
6
- alias_method :original_load_target, :load_target
7
-
8
- def load_target
9
- if proxy_association.reflection.sortable? and order_values.empty?
10
- sortable_table_name = (proxy_association.try(:through_reflection) || proxy_association.reflection).table_name
11
- order("#{sortable_table_name}.#{proxy_association.reflection.sortable_field} ASC").to_a
12
- else
13
- original_load_target
14
- end
15
- end
16
-
17
- end
18
- end
19
- end
@@ -1,16 +0,0 @@
1
- # encoding: utf-8
2
- module ActiveRecord
3
- module Reflection
4
- class ThroughReflection
5
-
6
- def sortable_field
7
- @delegate_reflection.options.fetch(:sortable_field, :position).to_sym
8
- end
9
-
10
- def sortable?
11
- @delegate_reflection.options.fetch(:sortable, false)
12
- end
13
-
14
- end
15
- end
16
- end