Ruby and Rails Rules Engine Framework

More detailed documentation at www.r3ef.com

Installation Guide

1. Create the Rails App


rails new MyCoolNewApp --skip-test-unit
cd MyCoolNewApp
rm ./public/index.html

2. Add & Install the gems

./Gemfile


gem 'rules_engine', '>= 0.3.0'
gem 'will_paginate', '>= 3.0.pre2'
gem 'acts_as_list', '>= 0.1.2'

group :development, :test do
  gem "rspec-rails", ">= 2.0.0.beta.22"
  gem "webrat"
  
  gem 'faker'
  gem 'machinist'  
end

bundle install

3. Set a Root Path

./config/routes.rb


root :to => "re_plans#index"

4. Generate the Code


script/rails generate rspec:install
script/rails generate rules_engine:install

5. Define the Access Levels

./app/controllers/application_controller.rb


class ApplicationController < ActionController::Base

  helper_method :rules_engine_reader?, :rules_engine_editor?
  
  def rules_engine_reader?
    # why cookies[:rules_engine_reader] ? It's a workaround for cucumber testing
    return cookies[:rules_engine_reader].nil? ? true : 
                                                cookies[:rules_engine_reader].downcase == 'true'
  end  
  
  def rules_engine_editor?
    # why cookies[:rules_engine_editor] ? It's a workaround for cucumber testing
    return cookies[:rules_engine_editor].nil? ? true : 
                                                cookies[:rules_engine_editor].downcase == 'true'
  end  

  def rules_engine_reader_access_required
    unless rules_engine_reader?    
      redirect_to(root_path) 
      flash[:success] = 'Rules Engine Access Denied.'
    end  
  end
  
  def rules_engine_editor_access_required
    unless rules_engine_editor?    
      redirect_to(root_path) 
      flash[:success] = 'Rules Engine Editor Access Denied.'
    end
  end

6. Migrate the Database


rake db:migrate
rake db:migrate RAILS_ENV=test

7. Create the Rule Scaffolds

Simple Rule


script/rails generate rules_engine:rule simple my_simple_rule

Complex Rule


script/rails generate rules_engine:rule complex my_complex_rule

8. Run the Tests


rake spec

9. Start the Server


script/rails server
open http://localhost:3000/re_pipelines

10. Create Workflows and Rules

Watch the demo at TODO