has_moderated 1.0.beta → 1.0.beta2
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.
- data/README.rdoc +13 -0
- data/lib/has_moderated/moderated_attributes.rb +4 -2
- data/lib/has_moderated/moderation_model.rb +4 -0
- data/lib/has_moderated/version.rb +1 -1
- data/test/dummy/log/development.log +13 -0
- data/test/dummy/log/test.log +1841 -0
- data/test/dummy/spec/models/task_spec.rb +17 -0
- metadata +3 -2
data/README.rdoc
CHANGED
@@ -79,6 +79,7 @@ Be especially careful if you are moderating a has_many :through association. In
|
|
79
79
|
has_moderated_association :bookshelves, :books
|
80
80
|
|
81
81
|
== Manage moderations
|
82
|
+
|
82
83
|
To see pending moderations, simply call
|
83
84
|
|
84
85
|
Moderation.all
|
@@ -106,6 +107,18 @@ to discard (destroy) it, call
|
|
106
107
|
|
107
108
|
Do not use moderation.destroy, because discard triggers certain callbacks which may be necessary.
|
108
109
|
|
110
|
+
== Preview moderation
|
111
|
+
|
112
|
+
You can see a preview of what a moderation will do. Right now, you can only preview changes to attributes, not associations. To create a preview of how a record will look after applying a moderation, use
|
113
|
+
|
114
|
+
record_preview = moderation.preview
|
115
|
+
|
116
|
+
This will return the record with modified attributes, but not saved to database. You can see what changed by looking at (provided by ActiveRecord)
|
117
|
+
|
118
|
+
record_preview.changes
|
119
|
+
|
120
|
+
Just be careful not to call record_preview.save, as this will create a new moderation record.
|
121
|
+
|
109
122
|
== Bypassing moderation
|
110
123
|
To bypass moderation (e.g. for admin users), wrap your code into without_moderation like so:
|
111
124
|
|
@@ -51,7 +51,7 @@ module HasModerated
|
|
51
51
|
end
|
52
52
|
|
53
53
|
module ApplyModeration
|
54
|
-
def self.apply(moderation, value)
|
54
|
+
def self.apply(moderation, value, do_save = true)
|
55
55
|
if value[:attributes].present?
|
56
56
|
rec = moderation.moderatable
|
57
57
|
rec.without_moderation do
|
@@ -59,9 +59,11 @@ module HasModerated
|
|
59
59
|
# bypass attr_accessible protection
|
60
60
|
rec.send(attr_name.to_s+"=", attr_value)
|
61
61
|
end
|
62
|
-
|
62
|
+
# don't run validations on save (were already ran when moderation was created)
|
63
|
+
rec.save(:validate => false) if do_save
|
63
64
|
end
|
64
65
|
end
|
66
|
+
rec
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
@@ -7528,3 +7528,16 @@ Migrating to CreatePhotos (20120520215224)
|
|
7528
7528
|
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("task_photos")[0m
|
7529
7529
|
[1m[35m (0.0ms)[0m PRAGMA index_list("tasks")
|
7530
7530
|
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("tasks_jointable")[0m
|
7531
|
+
DEPRECATION WARNING: ActiveSupport::Memoizable is deprecated and will be removed in future releases,simply use Ruby memoization pattern instead. (called from /Users/apple/rails/has_moderated/test/dummy/config/environment.rb:5)
|
7532
|
+
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
7533
|
+
Migrating to InitialSchema (20120520215008)
|
7534
|
+
Migrating to CreatePhotos (20120520215224)
|
7535
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
7536
|
+
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
7537
|
+
[1m[35m (0.0ms)[0m PRAGMA index_list("moderations")
|
7538
|
+
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("photos")[0m
|
7539
|
+
[1m[35m (0.0ms)[0m PRAGMA index_list("subtasks")
|
7540
|
+
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("task_connections")[0m
|
7541
|
+
[1m[35m (0.0ms)[0m PRAGMA index_list("task_photos")
|
7542
|
+
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("tasks")[0m
|
7543
|
+
[1m[35m (0.0ms)[0m PRAGMA index_list("tasks_jointable")
|