All Projects → yhirano55 → approval

yhirano55 / approval

Licence: MIT license
🙆‍♂️🙅 Approval flow for Rails

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to approval

Tabler Rubygem
Rubygem for https://tabler.github.io
Stars: ✭ 77 (-24.51%)
Mutual labels:  rails-engine
Flow core
FlowCore is a Rails engine to help you build your automation or business process application.
Stars: ✭ 120 (+17.65%)
Mutual labels:  rails-engine
Lines Engine
Lines is a customizable blog framework for Rails. It aims at making publishing simple and beautiful.
Stars: ✭ 191 (+87.25%)
Mutual labels:  rails-engine
Masq
Mountable Rails engine that provides OpenID server/identity provider functionality
Stars: ✭ 84 (-17.65%)
Mutual labels:  rails-engine
Adhoq
Rails engine to generate instant reports from adhoc SQL query.
Stars: ✭ 103 (+0.98%)
Mutual labels:  rails-engine
Redis web manager
Manage your Redis instance (see keys, memory used, connected client, etc...)
Stars: ✭ 139 (+36.27%)
Mutual labels:  rails-engine
Abraham
Trackable application tours for Rails with i18n support
Stars: ✭ 52 (-49.02%)
Mutual labels:  rails-engine
transam core
Core Rails engine for the TransAM open source software platform for managing transportation assets.
Stars: ✭ 13 (-87.25%)
Mutual labels:  rails-engine
Rails server timings
Server Timing headers for Rails apps
Stars: ✭ 112 (+9.8%)
Mutual labels:  rails-engine
Form core
A Rails engine providing ability to generate dynamic form.
Stars: ✭ 175 (+71.57%)
Mutual labels:  rails-engine
Thredded
The best Rails forums engine ever.
Stars: ✭ 1,263 (+1138.24%)
Mutual labels:  rails-engine
Exception Track
Tracking ⚠️ exceptions for Rails application and store them in database.
Stars: ✭ 102 (+0%)
Mutual labels:  rails-engine
Flipflop
Flipflop lets you declare and manage feature flags in your Rails application.
Stars: ✭ 165 (+61.76%)
Mutual labels:  rails-engine
Swagger ui engine
Include swagger-ui as rails engine and document your API with simple JSON or YAML files.
Stars: ✭ 77 (-24.51%)
Mutual labels:  rails-engine
Comfortable Mexican Sofa
ComfortableMexicanSofa is a powerful Ruby on Rails 5.2+ CMS (Content Management System) Engine
Stars: ✭ 2,707 (+2553.92%)
Mutual labels:  rails-engine
Sudo rails
🔒 Sudo mode for your Rails controllers
Stars: ✭ 66 (-35.29%)
Mutual labels:  rails-engine
Spotlight
Spotlight enables librarians, curators, and others who are responsible for digital collections to create attractive, feature-rich websites that highlight these collections.
Stars: ✭ 137 (+34.31%)
Mutual labels:  rails-engine
The-Ruby-Workshop
A New, Interactive Approach to Learning Ruby
Stars: ✭ 26 (-74.51%)
Mutual labels:  rails-engine
slackify
Build Slackbot on Rails using Slack Event API
Stars: ✭ 20 (-80.39%)
Mutual labels:  rails-engine
Workflow core
[Deprecated, use flor_core instead] A Rails engine which providing essential infrastructure of workflow. It's based on Workflow Nets.
Stars: ✭ 171 (+67.65%)
Mutual labels:  rails-engine

Approval

Build Status Gem Version

🙆‍♀️🙅Approval flow for Rails

Installation

  1. Add approval to your Gemfile:
gem 'approval'
  1. Add approval_requests, approval_comments, approval_items tables to your database and an initializer file for configuration:
$ bundle exec rails generate approval:install
  1. Add acts_as_approval_user to your user model (User, AdminUser, Member ...etc)::
class User < ApplicationRecord
  acts_as_approval_user
end
  1. Add acts_as_approval_resource to the models you want use approval flow:
class Book < ApplicationRecord
  acts_as_approval_resource
end

Or if you want to use PORO:

class SomeProcess
  def self.perform
    # something
  end
end

Approval Flow

Make request

You send request, but resources aren't created/updated/destroyed.

🙏 Create

staff = User.find_or_create_by(email: "[email protected]")

record  = Book.new(name: "Ruby Way", price: 2980)
request = staff.request_for_create(record, reason: "something")
request.save # Created Approval::Request record.

records = 10.times.map {|n| Book.new(name: "my_book_#{n}", price: 300) }
request = staff.request_for_create(records, reason: "something")
request.save!

🙏 Update

staff = User.find_or_create_by(email: "[email protected]")

record  = Book.find(1).tap {|record| record.name = "new book title" }
request = staff.request_for_update(record, reason: "something")
request.save

records = Book.where(id: [1, 2, 3]).each {|record| record.price *= 0.5 }
request = staff.request_for_update(records, reason: "something")
request.save!

🙏 Destroy

staff = User.find_or_create_by(email: "[email protected]")

record  = Book.find(1)
request = staff.request_for_destroy(record, reason: "something")
request.save

records = Book.where(id: [1, 2, 3])
request = staff.request_for_destroy(records, reason: "something")
request.save!

🙏 Perform

staff = User.find_or_create_by(email: "[email protected]")

record  = MyProcess.new(recipient: "[email protected]")
request = staff.request_for_perform(record, reason: "something")
request.save

Respond

🙆‍♀️ Approve

Then resources are created/updated/destroyed, if respond user have approved the request.

admin = User.find_or_create_by(email: "[email protected]")

request = Approval::Request.first
respond = admin.approve_request(request, reason: "something")
respond.save! # Create/Update/Destroy resources
🙅 Reject

Then resources are not created/updated/destroyed, if respond user have rejected the request.

admin = User.find_or_create_by(email: "[email protected]")

request = Approval::Request.first
respond = admin.reject_request(request, reason: "something")
respond.save!
🗑️ Cancel
staff = User.find_or_create_by(email: "[email protected]")

request = Approval::Request.first
respond = staff.cancel_request(request, reason: "something")
respond.save!

Comment

admin = User.find_or_create_by(email: "[email protected]")

request = Approval::Request.first
admin.approval_comments.create(request: request, content: "Hello")

Configuration

# config/initializers/approval.rb

Approval.configure do |config|
  # User Class Name (e.g: User, AdminUser, Member)
  config.user_class_name = "User"

  # Maximum characters of comment for reason (default: 2000)
  config.comment_maximum = 2000

  # Permit to respond to own request? (default: false)
  config.permit_to_respond_to_own_request = false
end

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].