Sha256: 6f11bea6ef1fb59335d15cc92295545a4532868ff22c082c35189801c61e2a90

Contents?: true

Size: 1.91 KB

Versions: 28

Compression:

Stored size: 1.91 KB

Contents

class ::IshManager::EmailActionsController < IshManager::ApplicationController

  before_action :set_lists

  ## Alphabetized : )

  def create
    @act = @email_action = Office::EmailAction.new
    authorize! :create, @act

    next_ids = params[:email_action].delete(:next_email_actions)
    next_ids.delete("")
    Office::EmailAction.where(prev_email_action_id: params[:id] ).update_all(prev_email_action_id: nil)
    next_ids.each do |next_id|
      next_action = ::Office::EmailAction.find next_id
      next_action.update_attribute( :prev_email_action_id, params[:id] )
    end

    flag = @act.update_attributes( params[:email_action].permit! )
    if flag
      flash[:notice] = 'Success'
    else
      flash[:alert] = "No luck: #{@act.errors.full_messages.join(', ')}"
    end

    redirect_to action: 'index'
  end

  def edit
    @act = @email_action = Office::EmailAction.find( params[:id] )
    authorize! :edit, @act
  end

  def index
    @email_actions = Office::EmailAction.all

    authorize! :index, @new_email_action
  end

  def new
    authorize! :new, @new_email_action
  end

  def show
  end

  def update
    @act = @email_action = Office::EmailAction.find( params[:id] )
    authorize! :update, @act

    next_ids = params[:email_action].delete(:next_email_actions)
    next_ids.delete("")
    Office::EmailAction.where(prev_email_action_id: params[:id] ).update_all(prev_email_action_id: nil)
    next_ids.each do |next_id|
      next_action = ::Office::EmailAction.find next_id
      next_action.update_attribute( :prev_email_action_id, params[:id] )
    end

    flag = @act.update_attributes( params[:email_action].permit! )
    if flag
      flash[:notice] = 'Success'
    else
      flash[:alert] = "No luck: #{@act.errors.full_messages.join(', ')}"
    end

    redirect_to action: 'index'
  end

  ##
  ## private
  ##
  private

  def set_lists
    @new_email_action = Office::EmailAction.new
    super
  end

end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
ish_manager-0.1.8.384 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.383 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.382 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.381 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.380 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.379 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.378 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.377 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.376 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.374 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.373 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.372 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.371 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.370 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.369 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.368 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.367 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.366 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.365 app/controllers/ish_manager/email_actions_controller.rb
ish_manager-0.1.8.364 app/controllers/ish_manager/email_actions_controller.rb