Skip to content
mrbrdo edited this page Oct 17, 2012 · 2 revisions

To bypass moderation (e.g. for admin users), wrap your code into without_moderation like so:

record.without_moderation(current_user.is_admin?) do
  record.update_attributes(...)
end

If the parameter is false, then it will have no effect. If the parameter is true, then moderations will be disabled for code inside the passed block. The parameter is optional and defaults to true.

You can also bypass moderation globally for all models by using Moderation.without_moderation (v1.1.2+):

Moderation.without_moderation(current_user.is_admin?) do
  record.update_attributes(...)
end

This can be especially useful when working with nested moderated models.