More thoughts on Acts As Draftable
I was thinking more about the Acts As Draftable plugin. I have been working on an Italian horror site that has various user levels (admin, vice-admin, contributor, users). Different rules apply when different types of users post content. A contributor article must be a approved by a vice-admin or admin user to get published on the front end, but if the admin is not happy with the article and not ready to publish, that higher level user can, instead of approving, choose to ‘give back’ the article to the contributor for further revisions. When the contributor is finished with their edits they can then ‘send again’ the article back to the admin for another shot at approval.
So I was thinking that with some small modifications, Acts As Draftable could serve a situation like this well. It would allow already approved articles to remain online while still being editable (in draft form) by the contributors or admins. It would also simplify the process of deciding what articles to show to whom - for the admin you could just query the drafts table, and for published articles you wouldn’t have to worry about constantly scoping to only the approved articles.
You could add a column to the drafts table to indicate whose ‘desk’ the article is currently on eg ‘Contributor’ or ‘Admin’ and through that search for ‘Returned’ articles by the contributor or ‘Submitted’ articles for the admin to review. To manage these different states you could add a few methods to the plugin, perhaps with the help of method_missing to make a smooth syntax, like so:
def save_as(type)
(draft || build_draft).update_attributes drafted_field_values
(draft || build_draft).update_attribute ('owner',"#{type}")
end
def method_missing(method, *args)
if find = method.to_s.match(/^save_(.*)_draft$/)
self.save_as(find[1])
else
super
end
end
This way, when a contributor posted or updated an article you could call save_as_admin_draft, the owner column would take the admin’ value. And when an admin wanted to ‘give back’ the article to the contributor you could call save_as_contributor draft to set the owner column to ‘contributor’.
I am available for Ruby on Rails consulting work – get in touch to learn more.