No commit activity in last 3 years
No release in over 3 years
Mongoid Approbation
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 2.0
 Project Readme

Mongoid Approbation

Mongoid Approbation will change the status of your model object before save it. For exemple if your are developping a Blog, you want that comments wrote by visitors are under your probation before publish it on your website If the user update his comment, this one will return to pending status

Quick Start

Add mongoid_approbation to your Gemfile:

gem 'mongoid_approbation'

Set up model:

class Comment
  include Mongoid::Document
  include Mongoid::Approbation

  field :title
  field :content

  under_approbation :default => :pending, :save_as => :pending, :accepted_status => [:pending, :accepted, :rejected]
end

Exemple :

	comment = Comment.new
	comment.title = "Hello world !"
	comment.save
	
	comment.status # <= pending
	
	#accept comment
	comment.set_status(:accepted)
	comment.save
	# same as :
	comment.save_as(:accepted)
	
	#reject comment
	comment.set_status(:rejected)
	comment.save
	# same as :
	comment.save_as(:accepted)
	

If the user update the comment, it will automatically return to pending status.

	comment.status # <= accepted
	comment.content = "i am the content"
	comment.save
	comment.status # <= pending

In your controller, use available finder:

# GET all pending comments
pending_comment = Comment.find_by_status(:pending)
published_comment = Comment.find_by_status(:accepted)

This gem is use on Passion Gourmande