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
-
#current_account ⇒ Account
Get the current account.
-
#ensure_onboarded ⇒ Redirect?
Redirect to onboarding if user is not onboarded.
-
#ensure_team_account ⇒ Redirect?
Ensure that the user has selected a team account before proceeding.
-
#onboarded? ⇒ Boolean
Check if the user is onboarded.
-
#personal_account ⇒ Account
Get the personal account of the user.
-
#render_flash_messages_stream ⇒ Object
Render flash messages as turbo stream.
Instance Method Details
#current_account ⇒ Account
Get the current account
14 15 16 |
# File 'lib/kiqr/controllers/helpers.rb', line 14 def current_account Kiqr::CurrentAttributes.account end |
#ensure_onboarded ⇒ Redirect?
Redirect to onboarding if user is not onboarded
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_account ⇒ Redirect?
Ensure that the user has selected a team account before proceeding.
40 41 42 43 44 45 |
# File 'lib/kiqr/controllers/helpers.rb', line 40 def ensure_team_account unless current_account.team? :alert, :team_account_required redirect_to dashboard_path end end |
#onboarded? ⇒ Boolean
Check if the user is onboarded
20 21 22 |
# File 'lib/kiqr/controllers/helpers.rb', line 20 def onboarded? current_user&.onboarded? end |
#personal_account ⇒ Account
Get the personal account of the user
26 27 28 |
# File 'lib/kiqr/controllers/helpers.rb', line 26 def personal_account current_user&.personal_account end |
#render_flash_messages_stream ⇒ Object
Render flash messages as turbo stream
48 49 50 |
# File 'lib/kiqr/controllers/helpers.rb', line 48 def turbo_stream.replace("flash_messages", partial: "kiqr/shared/flash_messages") end |