Class: RePlansController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- RePlansController
- Defined in:
- app/controllers/re_plans_controller.rb
Instance Method Summary collapse
- #change ⇒ Object
- #copy ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #duplicate ⇒ Object
- #edit ⇒ Object
- #history ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #preview ⇒ Object
- #publish ⇒ Object
- #revert ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#change ⇒ Object
82 83 |
# File 'app/controllers/re_plans_controller.rb', line 82 def change end |
#copy ⇒ Object
132 133 134 |
# File 'app/controllers/re_plans_controller.rb', line 132 def copy @re_plan_copy = RePlan.new end |
#create ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/re_plans_controller.rb', line 26 def create @re_plan = RePlan.new(params[:re_plan]) if @re_plan.save flash[:success] = 'Plan Created.' respond_to do |format| format.html do redirect_to(change_re_plan_path(@re_plan)) end format.js do render :action => "create" end end else render :action => "new" end end |
#destroy ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/controllers/re_plans_controller.rb', line 67 def destroy RulesEngine::Publish.publisher.remove(@re_plan.code) @re_plan.destroy flash[:success] = 'Plan Deleted.' respond_to do |format| format.html do redirect_to(re_plans_path) end format.js do render :inline => "window.location.href = '#{re_plans_path}';" end end end |
#duplicate ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'app/controllers/re_plans_controller.rb', line 136 def duplicate @re_plan_copy = RePlan.new @re_plan_copy.revert!(@re_plan.publish) @re_plan_copy.attributes = params[:re_plan] if @re_plan_copy.save flash[:success] = 'Plan Duplicated.' respond_to do |format| format.html do redirect_to(change_re_plan_path(@re_plan_copy)) end format.js do render :inline => "window.location.href = '#{change_re_plan_path(@re_plan_copy)}';" end end else render :action => "copy" end end |
#edit ⇒ Object
45 46 |
# File 'app/controllers/re_plans_controller.rb', line 45 def edit end |
#history ⇒ Object
128 129 130 |
# File 'app/controllers/re_plans_controller.rb', line 128 def history @re_history = RulesEngine::Process.runner.history(@re_plan.code, :page => params[:page] || 1, :per_page => 5) end |
#index ⇒ Object
13 14 15 16 17 |
# File 'app/controllers/re_plans_controller.rb', line 13 def index klass = RePlan @re_plans = klass.order_title @re_plans = klass.find(:all) end |
#new ⇒ Object
22 23 24 |
# File 'app/controllers/re_plans_controller.rb', line 22 def new @re_plan = RePlan.new end |
#preview ⇒ Object
85 86 |
# File 'app/controllers/re_plans_controller.rb', line 85 def preview end |
#publish ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'app/controllers/re_plans_controller.rb', line 88 def publish if params['tag'].blank? flash[:error] = 'Tag Required.' else @re_plan.plan_version = RulesEngine::Publish.publisher.publish(@re_plan.code, params['tag'], @re_plan.publish) @re_plan.plan_status = RePlan::PLAN_STATUS_PUBLISHED @re_plan.save flash[:success] = 'Plan Published.' end respond_to do |format| format.html do redirect_to(change_re_plan_path(@re_plan)) end format.js do render :action => "update" end end end |
#revert ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'app/controllers/re_plans_controller.rb', line 108 def revert plan = RulesEngine::Publish.publisher.get(@re_plan.code) if plan.nil? flash[:error] = 'Cannot Find Published Plan.' else @re_plan.revert!(plan) @re_plan.save! flash[:success] = 'Changes Discarded.' end respond_to do |format| format.html do redirect_to(change_re_plan_path(@re_plan)) end format.js do render :action => "update" end end end |
#show ⇒ Object
19 20 |
# File 'app/controllers/re_plans_controller.rb', line 19 def show end |
#update ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/re_plans_controller.rb', line 48 def update update_params = params[:re_plan] || {} @re_plan.attributes = update_params.except(:code) if @re_plan.save flash[:success] = 'Plan Updated.' respond_to do |format| format.html do redirect_to(change_re_plan_path(@re_plan)) end format.js do render :action => "update" end end else render :action => "edit" end end |