Class: Wco::OfficeActionTemplatesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Wco::OfficeActionTemplatesController
- Defined in:
- app/controllers/wco/office_action_templates_controller.rb
Instance Method Summary collapse
Instance Method Details
#edit ⇒ Object
6 7 8 9 10 |
# File 'app/controllers/wco/office_action_templates_controller.rb', line 6 def edit @oat = OAT.find params[:id] @oat.ties.push Wco::OfficeActionTemplateTie.new :edit, @oat end |
#index ⇒ Object
12 13 14 15 16 17 |
# File 'app/controllers/wco/office_action_templates_controller.rb', line 12 def index :index, OAT @oats = OAT.all @new_oat = OAT.new @new_oat.ties.push Wco::OfficeActionTemplateTie.new end |
#new ⇒ Object
19 20 21 22 23 |
# File 'app/controllers/wco/office_action_templates_controller.rb', line 19 def new @oat = OAT.new @oat.ties.push Wco::OfficeActionTemplateTie.new :new, @oat end |
#perform ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/wco/office_action_templates_controller.rb', line 25 def perform @oat = OAT.find params[:id] :run, @oat @conversations = WcoEmail::Conversation.find( params[:conversation_ids] ) if params[:conversation_ids].present? if 'rb' == @oat.action_type out = eval( @oat.action_exe ) elsif 'sh' == @oat.action_type out = `#{@oat.action_exe}` end flash_notice out redirect_to action: :index end |
#show ⇒ Object
38 39 40 41 |
# File 'app/controllers/wco/office_action_templates_controller.rb', line 38 def show @oat = OAT.find params[:id] :show, @oat end |
#update ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/wco/office_action_templates_controller.rb', line 43 def update params[:oat][:ties_attributes].permit! rescue nil if params[:id] @oat = OAT.find params[:id] else @oat = OAT.new end :upsert, @oat if params[:oat][:ties_attributes] params[:oat][:ties_attributes].each do |k, v| if !v[:next_office_action_template_id].present? params[:oat][:ties_attributes].delete( k ) end if v[:to_delete] == "1" OATT.find( v[:id] ).delete params[:oat][:ties_attributes].delete( k ) end end end if @oat.update params[:oat].permit! flash_notice @oat else flash_alert @oat end redirect_to action: :index end |