has_moderated 0.0.24 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,7 +32,12 @@ module HasModerated
32
32
  if assoc.macro == :has_and_belongs_to_many || !assoc.options[:through].blank?
33
33
  arec.send(rec.class.to_s.underscore.pluralize) << rec
34
34
  elsif assoc.macro == :has_many || assoc.macro == :has_one
35
- arec.send(rec.class.to_s.underscore + "=", rec)
35
+ field = if assoc.options[:as]
36
+ assoc.options[:as].to_s
37
+ else
38
+ rec.class.to_s.underscore
39
+ end
40
+ arec.send(field + "=", rec)
36
41
  #fk = if assoc.respond_to?(:foreign_key)
37
42
  # assoc.foreign_key
38
43
  #else # Rails < v3.1
@@ -1,3 +1,3 @@
1
1
  module HasModerated
2
- VERSION = "0.0.24"
2
+ VERSION = "0.0.25"
3
3
  end
@@ -0,0 +1,3 @@
1
+ class HoneAsTest < ActiveRecord::Base
2
+ belongs_to :testable, :polymorphic => true
3
+ end
@@ -4,10 +4,11 @@ class Task < ActiveRecord::Base
4
4
  has_many :task_photos
5
5
  has_and_belongs_to_many :hjoin_tests
6
6
  has_one :hone_test
7
+ has_one :hone_as_test, :as => :testable
7
8
  has_many :hmanythrough_join
8
9
  has_many :hmanythrough_test, :through => :hmanythrough_join
9
10
  has_moderated :title, :desc
10
- has_moderated_create :with_associations => [:subtasks, :task_photos, :hjoin_tests, :hone_test, :hmanythrough_test, :hmanythrough_join]
11
+ has_moderated_create :with_associations => [:subtasks, :task_photos, :hjoin_tests, :hone_test, :hmanythrough_test, :hmanythrough_join, :hone_as_test]
11
12
  has_moderated_association :all
12
13
  has_moderated_destroy
13
14
  end
Binary file
@@ -0,0 +1,11 @@
1
+ class CreateHoneAsTests < ActiveRecord::Migration
2
+ def change
3
+ create_table :hone_as_tests do |t|
4
+ t.integer :testable_id
5
+ t.string :testable_type
6
+ t.string :title
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended to check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(:version => 20111009205545) do
13
+ ActiveRecord::Schema.define(:version => 20111018172409) do
14
14
 
15
15
  create_table "hjoin_tests", :force => true do |t|
16
16
  t.string "title"
@@ -37,6 +37,14 @@ ActiveRecord::Schema.define(:version => 20111009205545) do
37
37
  t.datetime "updated_at"
38
38
  end
39
39
 
40
+ create_table "hone_as_tests", :force => true do |t|
41
+ t.integer "testable_id"
42
+ t.string "testable_type"
43
+ t.string "title"
44
+ t.datetime "created_at"
45
+ t.datetime "updated_at"
46
+ end
47
+
40
48
  create_table "hone_tests", :force => true do |t|
41
49
  t.integer "task_id"
42
50
  t.datetime "created_at"
Binary file
@@ -6049,3 +6049,145 @@ Migrating to CreateHmanythroughJoins (20111009205545)
6049
6049
   (1.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20111009193145')
6050
6050
   (1.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20111009201729')
6051
6051
   (2.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20111009205517')
6052
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
6053
+  (0.1ms) select sqlite_version(*)
6054
+  (1.8ms) CREATE TABLE "hjoin_tests" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "created_at" datetime, "updated_at" datetime) 
6055
+  (1.4ms) CREATE TABLE "hjoin_tests_tasks" ("task_id" integer, "hjoin_test_id" integer)
6056
+  (1.6ms) CREATE TABLE "hmanythrough_joins" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "hmanythrough_test_id" integer, "task_id" integer, "exdata" varchar(255), "created_at" datetime, "updated_at" datetime) 
6057
+  (1.5ms) CREATE TABLE "hmanythrough_tests" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "created_at" datetime, "updated_at" datetime)
6058
+  (1.7ms) CREATE TABLE "hone_tests" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "task_id" integer, "created_at" datetime, "updated_at" datetime, "title" varchar(255)) 
6059
+  (1.6ms) CREATE TABLE "hook_tests" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "foo" varchar(255), "created_at" datetime, "updated_at" datetime)
6060
+  (1.7ms) CREATE TABLE "moderations" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "moderatable_id" integer, "moderatable_type" varchar(255) NOT NULL, "attr_name" varchar(60) NOT NULL, "attr_value" text NOT NULL, "created_at" datetime, "updated_at" datetime) 
6061
+  (1.5ms) CREATE TABLE "photo_holders" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "created_at" datetime, "updated_at" datetime)
6062
+  (1.9ms) CREATE TABLE "photos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "photo" varchar(255), "created_at" datetime, "updated_at" datetime, "photo_holder_id" integer) 
6063
+  (1.6ms) CREATE TABLE "subtasks" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "task_id" integer, "title" varchar(255), "desc" varchar(255), "created_at" datetime, "updated_at" datetime, "task_all_id" integer)
6064
+  (1.6ms) CREATE TABLE "task_alls" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "value" varchar(255), "created_at" datetime, "updated_at" datetime) 
6065
+  (2.5ms) CREATE TABLE "task_photos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "photo" varchar(255), "task_id" integer, "created_at" datetime, "updated_at" datetime)
6066
+  (1.6ms) CREATE TABLE "tasks" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "desc" varchar(255), "created_at" datetime, "updated_at" datetime) 
6067
+  (1.8ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
6068
+  (0.0ms) PRAGMA index_list("schema_migrations")
6069
+  (1.5ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6070
+  (0.1ms) SELECT version FROM "schema_migrations"
6071
+  (2.2ms) INSERT INTO "schema_migrations" (version) VALUES ('20111009205545')
6072
+  (1.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20110901013205')
6073
+  (1.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20110901013228')
6074
+  (2.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20110901013618')
6075
+  (1.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20110908025410')
6076
+  (2.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20110908025606')
6077
+  (1.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20111003205633')
6078
+  (1.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20111003234101')
6079
+  (1.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20111004153147')
6080
+  (1.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20111004164509')
6081
+  (1.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20111008195728')
6082
+  (2.2ms) INSERT INTO "schema_migrations" (version) VALUES ('20111008195809')
6083
+  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20111009193145')
6084
+  (1.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20111009201729')
6085
+  (1.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20111009205517')
6086
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
6087
+ Migrating to CreateTasks (20110901013205)
6088
+ Migrating to CreateSubtasks (20110901013228)
6089
+ Migrating to CreateModerations (20110901013618)
6090
+ Migrating to CreateTaskAlls (20110908025410)
6091
+ Migrating to AddTaskAllIdToSubtasks (20110908025606)
6092
+ Migrating to CreatePhotos (20111003205633)
6093
+ Migrating to CreateTaskPhotos (20111003234101)
6094
+ Migrating to CreateHookTests (20111004153147)
6095
+ Migrating to CreatePhotoHolders (20111004164509)
6096
+ Migrating to CreateHoneTests (20111008195728)
6097
+ Migrating to CreateHjoinTests (20111008195809)
6098
+ Migrating to FixJoinTable (20111009193145)
6099
+ Migrating to AddTitleToHoneTests (20111009201729)
6100
+ Migrating to CreateHmanythroughTests (20111009205517)
6101
+ Migrating to CreateHmanythroughJoins (20111009205545)
6102
+ Migrating to CreateHoneAsTests (20111018172409)
6103
+  (0.0ms) select sqlite_version(*)
6104
+  (0.6ms) CREATE TABLE "hone_as_tests" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "testable_id" integer, "testable_type" varchar(255), "title" varchar(255), "created_at" datetime, "updated_at" datetime) 
6105
+  (16.5ms) INSERT INTO "schema_migrations" ("version") VALUES ('20111018172409')
6106
+  (0.1ms) select sqlite_version(*)
6107
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
6108
+  (0.0ms) PRAGMA index_list("hjoin_tests")
6109
+  (0.0ms) PRAGMA index_list("hjoin_tests_tasks")
6110
+  (0.0ms) PRAGMA index_list("hmanythrough_joins")
6111
+  (0.0ms) PRAGMA index_list("hmanythrough_tests")
6112
+  (0.0ms) PRAGMA index_list("hone_as_tests")
6113
+  (0.0ms) PRAGMA index_list("hone_tests")
6114
+  (0.0ms) PRAGMA index_list("hook_tests")
6115
+  (0.0ms) PRAGMA index_list("moderations")
6116
+  (0.0ms) PRAGMA index_list("photo_holders")
6117
+  (0.0ms) PRAGMA index_list("photos")
6118
+  (0.0ms) PRAGMA index_list("subtasks")
6119
+  (0.0ms) PRAGMA index_list("task_alls")
6120
+  (0.0ms) PRAGMA index_list("task_photos")
6121
+  (0.0ms) PRAGMA index_list("tasks")
6122
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
6123
+  (0.1ms) select sqlite_version(*)
6124
+  (2.8ms) CREATE TABLE "hjoin_tests" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "created_at" datetime, "updated_at" datetime) 
6125
+  (1.6ms) CREATE TABLE "hjoin_tests_tasks" ("task_id" integer, "hjoin_test_id" integer)
6126
+  (1.7ms) CREATE TABLE "hmanythrough_joins" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "hmanythrough_test_id" integer, "task_id" integer, "exdata" varchar(255), "created_at" datetime, "updated_at" datetime) 
6127
+  (1.2ms) CREATE TABLE "hmanythrough_tests" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "created_at" datetime, "updated_at" datetime)
6128
+  (1.4ms) CREATE TABLE "hone_as_tests" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "testable_id" integer, "testable_type" varchar(255), "title" varchar(255), "created_at" datetime, "updated_at" datetime) 
6129
+  (1.9ms) CREATE TABLE "hone_tests" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "task_id" integer, "created_at" datetime, "updated_at" datetime, "title" varchar(255))
6130
+  (1.6ms) CREATE TABLE "hook_tests" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "foo" varchar(255), "created_at" datetime, "updated_at" datetime) 
6131
+  (1.5ms) CREATE TABLE "moderations" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "moderatable_id" integer, "moderatable_type" varchar(255) NOT NULL, "attr_name" varchar(60) NOT NULL, "attr_value" text NOT NULL, "created_at" datetime, "updated_at" datetime)
6132
+  (2.1ms) CREATE TABLE "photo_holders" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "created_at" datetime, "updated_at" datetime) 
6133
+  (1.5ms) CREATE TABLE "photos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "photo" varchar(255), "created_at" datetime, "updated_at" datetime, "photo_holder_id" integer)
6134
+  (1.7ms) CREATE TABLE "subtasks" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "task_id" integer, "title" varchar(255), "desc" varchar(255), "created_at" datetime, "updated_at" datetime, "task_all_id" integer) 
6135
+  (1.7ms) CREATE TABLE "task_alls" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "value" varchar(255), "created_at" datetime, "updated_at" datetime)
6136
+  (2.3ms) CREATE TABLE "task_photos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "photo" varchar(255), "task_id" integer, "created_at" datetime, "updated_at" datetime) 
6137
+  (1.8ms) CREATE TABLE "tasks" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "desc" varchar(255), "created_at" datetime, "updated_at" datetime)
6138
+  (1.7ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
6139
+  (0.0ms) PRAGMA index_list("schema_migrations")
6140
+  (2.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6141
+  (0.1ms) SELECT version FROM "schema_migrations"
6142
+  (1.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20111018172409')
6143
+  (1.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20110901013205')
6144
+  (1.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20110901013228')
6145
+  (1.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20110901013618')
6146
+  (1.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20110908025410')
6147
+  (1.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20110908025606')
6148
+  (2.2ms) INSERT INTO "schema_migrations" (version) VALUES ('20111003205633')
6149
+  (1.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20111003234101')
6150
+  (1.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20111004153147')
6151
+  (1.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20111004164509')
6152
+  (1.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20111008195728')
6153
+  (1.2ms) INSERT INTO "schema_migrations" (version) VALUES ('20111008195809')
6154
+  (1.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20111009193145')
6155
+  (2.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20111009201729')
6156
+  (1.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20111009205517')
6157
+  (1.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20111009205545')
6158
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
6159
+  (0.1ms) select sqlite_version(*)
6160
+  (2.7ms) CREATE TABLE "hjoin_tests" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "created_at" datetime, "updated_at" datetime) 
6161
+  (1.9ms) CREATE TABLE "hjoin_tests_tasks" ("task_id" integer, "hjoin_test_id" integer)
6162
+  (1.5ms) CREATE TABLE "hmanythrough_joins" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "hmanythrough_test_id" integer, "task_id" integer, "exdata" varchar(255), "created_at" datetime, "updated_at" datetime) 
6163
+  (1.4ms) CREATE TABLE "hmanythrough_tests" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "created_at" datetime, "updated_at" datetime)
6164
+  (1.7ms) CREATE TABLE "hone_as_tests" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "testable_id" integer, "testable_type" varchar(255), "title" varchar(255), "created_at" datetime, "updated_at" datetime) 
6165
+  (1.3ms) CREATE TABLE "hone_tests" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "task_id" integer, "created_at" datetime, "updated_at" datetime, "title" varchar(255))
6166
+  (1.8ms) CREATE TABLE "hook_tests" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "foo" varchar(255), "created_at" datetime, "updated_at" datetime) 
6167
+  (1.4ms) CREATE TABLE "moderations" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "moderatable_id" integer, "moderatable_type" varchar(255) NOT NULL, "attr_name" varchar(60) NOT NULL, "attr_value" text NOT NULL, "created_at" datetime, "updated_at" datetime)
6168
+  (1.7ms) CREATE TABLE "photo_holders" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "created_at" datetime, "updated_at" datetime) 
6169
+  (1.6ms) CREATE TABLE "photos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "photo" varchar(255), "created_at" datetime, "updated_at" datetime, "photo_holder_id" integer)
6170
+  (1.5ms) CREATE TABLE "subtasks" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "task_id" integer, "title" varchar(255), "desc" varchar(255), "created_at" datetime, "updated_at" datetime, "task_all_id" integer) 
6171
+  (1.6ms) CREATE TABLE "task_alls" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "value" varchar(255), "created_at" datetime, "updated_at" datetime)
6172
+  (1.8ms) CREATE TABLE "task_photos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "photo" varchar(255), "task_id" integer, "created_at" datetime, "updated_at" datetime) 
6173
+  (1.6ms) CREATE TABLE "tasks" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "desc" varchar(255), "created_at" datetime, "updated_at" datetime)
6174
+  (1.9ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
6175
+  (0.0ms) PRAGMA index_list("schema_migrations")
6176
+  (2.5ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6177
+  (0.1ms) SELECT version FROM "schema_migrations"
6178
+  (1.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20111018172409')
6179
+  (2.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20110901013205')
6180
+  (1.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20110901013228')
6181
+  (2.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20110901013618')
6182
+  (1.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20110908025410')
6183
+  (1.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20110908025606')
6184
+  (1.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20111003205633')
6185
+  (1.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20111003234101')
6186
+  (1.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20111004153147')
6187
+  (2.2ms) INSERT INTO "schema_migrations" (version) VALUES ('20111004164509')
6188
+  (1.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20111008195728')
6189
+  (1.2ms) INSERT INTO "schema_migrations" (version) VALUES ('20111008195809')
6190
+  (1.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20111009193145')
6191
+  (1.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20111009201729')
6192
+  (1.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20111009205517')
6193
+  (2.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20111009205545')