module Kiqr::Controllers::Helpers
Those helpers are convenience methods added to ApplicationController.
Public Instance Methods
Method used by accounts controller to redirect the user after an account has been setup and validated. You can overwrite it in your ApplicationController to provide a custom url.
# File lib/kiqr/core/controllers/helpers.rb, line 19 def after_account_setup_path root_path end
Method used by accounts controller to redirect the user after a user has switched to another account. You can overwrite it in your ApplicationController to provide a custom url.
# File lib/kiqr/core/controllers/helpers.rb, line 26 def after_account_switched_path root_path end
Method used by accounts controller to redirect the user after an account has been updated. You can overwrite it in your ApplicationController to provide a custom url. Default is to stay on the edit page.
# File lib/kiqr/core/controllers/helpers.rb, line 34 def after_account_updated_path edit_account_path end
Override cancancan's default current_ability
to authorize actions depending on the current_member
role and subscription plan. You can overwrite it in your ApplicationController if you want to build a custom authorization strategy.
# File lib/kiqr/core/controllers/helpers.rb, line 42 def current_ability @current_ability ||= Ability.new(current_member, current_subscription_plan) end
Current
signed-in account. You can overwrite this by setting the global variable @current_account to another Account in a controller. However, It's not recommended to overwrite current_account
, but we'll leave the opportunity here in case you'll have to.
# File lib/kiqr/core/controllers/helpers.rb, line 50 def current_account @current_account || Kiqr::Current.account end
Current
signed-in member (user-to-account association). Can be used to validate that a user is a member of the current_account
or for example to get the current member role with current_member.role?('admin')
# File lib/kiqr/core/controllers/helpers.rb, line 57 def current_member return unless user_signed_in? current_account.members.find_by(user: current_user) end
Return the current_account
's current subscription plan. This is currently a placeholder method, until a good subscription strategy has been developed. It's added temporary so that we can build generators for cancancan's Ability staretegies.
# File lib/kiqr/core/controllers/helpers.rb, line 67 def current_subscription_plan return unless user_signed_in? && current_account.present? end
Check if flash messages should be emitted. Default is to do it on navigational formats
# File lib/kiqr/core/controllers/helpers.rb, line 73 def flashing_format? request.respond_to?(:flash) && navigational_format? end