views:

122

answers:

3

Hi all,

I'm creating CMS where created and updated posts have to be moderated. Ie. user Bill updates post - new content is stored somewhere in database. Unless cms-admin accepts Bill's post visitors should see post content before Bill's update. When cms-admin accepts new post content visitors see fresh version.

I think about using acts_as_versioned or acts_as_revisible but neither do exactly what I want. Do you have any experience with that topic?

ML

A: 

Sounds like a business logic problem to me. Why aren't you just using a couple of duplicate fields and then filtering doing something similar to:

Post.find(:all, :conditions => {:approved => true })

The syntax may not be correct. Only working with rails for a few days now, but the idea should be clear. Basically, modify posts to have an approved flag and approved text, set them when the admin "approves" the post, and be done with it.

I feel you're trying to over-complicate it. Do you have a specific need to make the posts auditable? I know carrying two fields seems a bit wasteful, but you can always empty out the "unapprovedText" field after the post has been approved and it will use less storage than a full audit trail.

andymeadows
A: 

thanks for your answer.

Your concept is clean and simple, I like it, but unfortunately I need something more powerful. Posts redactors should have possibility to track changes - with your idea it's practically impossible.

I've implemented that with acts_as_versioned. After post edition a new version of post is created in item_versions table. Visitors still see old version (last moderated) from items table, but moderator can see all versions of post and accept chosen one. With acts_as_versioned one can manipulate versions history, ie. users can track only 10, 50 or 100 last post versions.

mlomnicki
+1  A: 

You could use a versioning plugin like acts_as_versioned or vestal_versions (railscasts.com)

Assuming you have Post model, you could add a field like display_version. Users would always see the version of the post corresponding to the version number in display_version. Only the cms-admin would be able to change the number in this field to the new version.

Calavera
It's currently solved using acts_as_versioned, however the solution is overcomplicated when versioning model with associations. Situation is even worse when attachments versioning is needed. I would love to see clear solution for this issue. In my opinion acts_as_versioned as well as vestal_versions solve problem only partially.
mlomnicki