Class: Kaui::AccountEmailsController

Inherits:
EngineController show all
Defined in:
app/controllers/kaui/account_emails_controller.rb

Constant Summary

Constants included from EngineControllerUtil

EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD

Instance Method Summary collapse

Methods inherited from EngineController

#check_for_redirect_to_tenant_screen, #current_ability, #current_user, #options_for_klient, #populate_account_details, #retrieve_allowed_users_for_current_user, #retrieve_tenants_for_current_user

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/kaui/account_emails_controller.rb', line 8

def create
  @account_email = Kaui::AccountEmail.new(.merge(:account_id => params.require(:account_id)))

  begin
    @account_email.create(current_user.kb_username, params[:reason], params[:comment], options_for_klient)
    redirect_to kaui_engine.(@account_email.), :notice => 'Account email was successfully added'
  rescue => e
    flash.now[:error] = "Error while adding the email: #{as_string(e)}"
    render :action => :new
  end
end

#destroyObject



20
21
22
23
24
25
26
27
# File 'app/controllers/kaui/account_emails_controller.rb', line 20

def destroy
   = Kaui::AccountEmail.new(:account_id => params.require(:account_id),
                                         :email => params.require(:id))

  .destroy(current_user.kb_username, params[:reason], params[:comment], options_for_klient)

  redirect_to kaui_engine.(.), :notice => 'Account email was successfully deleted'
end

#newObject



3
4
5
6
# File 'app/controllers/kaui/account_emails_controller.rb', line 3

def new
  @account_email = Kaui::AccountEmail.new(:account_id => params.require(:account_id),
                                          :email => params[:email])
end