Module: Kiqr::Controllers::Helpers

Extended by:
ActiveSupport::Concern
Defined in:
lib/kiqr/controllers/helpers.rb

Overview

These helpers are methods added to ApplicationController automatically when the engine is loaded.

Instance Method Summary collapse

Instance Method Details

#current_accountAccount

Get the current account

Returns:

  • (Account)

    the current account



14
15
16
# File 'lib/kiqr/controllers/helpers.rb', line 14

def 
  Kiqr::CurrentAttributes.
end

#ensure_onboardedRedirect?

Redirect to onboarding if user is not onboarded

Returns:

  • (Redirect, nil)


32
33
34
35
36
# File 'lib/kiqr/controllers/helpers.rb', line 32

def ensure_onboarded
  return if devise_controller? # Skip onboarding check for devise controllers

  redirect_to onboarding_path if user_signed_in? && !current_user.onboarded?
end

#ensure_team_accountRedirect?

Ensure that the user has selected a team account before proceeding.

Returns:

  • (Redirect, nil)


40
41
42
43
44
45
# File 'lib/kiqr/controllers/helpers.rb', line 40

def 
  unless .team?
    kiqr_flash_message :alert, :team_account_required
    redirect_to dashboard_path
  end
end

#onboarded?Boolean

Check if the user is onboarded

Returns:

  • (Boolean)

    true if the user is onboarded



20
21
22
# File 'lib/kiqr/controllers/helpers.rb', line 20

def onboarded?
  current_user&.onboarded?
end

#personal_accountAccount

Get the personal account of the user

Returns:

  • (Account)

    the personal account of the user



26
27
28
# File 'lib/kiqr/controllers/helpers.rb', line 26

def 
  current_user&.
end

#render_flash_messages_streamObject

Render flash messages as turbo stream



48
49
50
# File 'lib/kiqr/controllers/helpers.rb', line 48

def render_flash_messages_stream
  turbo_stream.replace("flash_messages", partial: "kiqr/shared/flash_messages")
end