Class: IshManager::EmailActionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- IshManager::EmailActionsController
- Defined in:
- app/controllers/ish_manager/email_actions_controller.rb
Instance Method Summary collapse
-
#edit ⇒ Object
Alphabetized : ).
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
-
#update ⇒ Object
def create; update; end def upsert; update; end.
Methods inherited from ApplicationController
Instance Method Details
#edit ⇒ Object
Alphabetized : )
8 9 10 11 12 |
# File 'app/controllers/ish_manager/email_actions_controller.rb', line 8 def edit @act = @email_action = Office::EmailAction.find( params[:id] ) @act.ties.push Office::EmailActionTie.new( next_email_action_id: nil ) :edit, @act end |
#index ⇒ Object
14 15 16 17 18 |
# File 'app/controllers/ish_manager/email_actions_controller.rb', line 14 def index @email_actions = Office::EmailAction.all :index, @new_email_action end |
#new ⇒ Object
20 21 22 |
# File 'app/controllers/ish_manager/email_actions_controller.rb', line 20 def new :new, @new_email_action end |
#show ⇒ Object
24 25 26 27 |
# File 'app/controllers/ish_manager/email_actions_controller.rb', line 24 def show @act = @email_action = Office::EmailAction.find( params[:id] ) :show, @act end |
#update ⇒ Object
def create; update; end def upsert; update; end
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/ish_manager/email_actions_controller.rb', line 31 def update if params[:id] @act = @email_action = Office::EmailAction.find( params[:id] ) else @act = @email_action = Office::EmailAction.new end :upsert, @act if params[:email_action][:ties_attributes] params[:email_action][:ties_attributes].each do |k, v| if !v[:next_email_action_id].present? params[:email_action][:ties_attributes].delete( k ) end if v[:to_delete] == "1" Actie.find( v[:id] ).delete params[:email_action][:ties_attributes].delete( k ) end end end flag = @act.update_attributes( params[:email_action].permit! ) if flag flash[:notice] = 'Success' redirect_to action: 'index' else flash[:alert] = "No luck: #{@act.errors..join(', ')}. #{@act.ties.map { |t| t.errors..join(', ') }.join(' | ') }" render action: 'edit' end end |