Skip to content

Attributes, create, destroy

mrbrdo edited this page Jun 13, 2012 · 4 revisions

Always put has_moderated after has_many etc. in your model!

Attributes

To moderate one or more attributes, add

has_moderated :attr1, :attr2

to your model.

Create

If you want to moderate the creation of a record (for example, you don’t want new blog posts to show up until they are accepted by a moderator), use

has_moderated_create

You can also specify associations that need to be saved for moderation as well (if moderating the creation of new records) - for example, if a Post has_many :links, and you want to submit these links to moderation as well (note, if you don’t, they will be discarded), use

has_moderated_create :with_associations => [:links]

in your Post model (post.rb). This only matters when you use has_moderated_create. You can also use

has_moderated_create :with_associations => :all

to include all associations, but I recommend you explicitly specify them if possible. By default, no associations are included.

Destroy

To moderate destruction of records, use

has_moderated_destroy