Class: Kaui::AccountChildrenController
- Inherits:
-
EngineController
- Object
- ApplicationController
- EngineController
- Kaui::AccountChildrenController
- Defined in:
- app/controllers/kaui/account_children_controller.rb
Constant Summary
Constants included from EngineControllerUtil
EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD
Instance Method Summary collapse
- #index ⇒ Object
-
#pagination ⇒ Object
It will fetch all the children.
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
#index ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/controllers/kaui/account_children_controller.rb', line 4 def index # check that the required parent account id is provided and get its data begin @account = Kaui::Account::find_by_id(params.require(:account_id), false, false, ) rescue KillBillClient::API::NotFound flash[:error] = "Invalid parent account id supplied #{params.require(:account_id)}" redirect_to kaui_engine.home_path and return end end |
#pagination ⇒ Object
It will fetch all the children. It use the paginate to fetch all children as permitting for future exchange when killbill account/account_id/children endpoint includes offset and limit parameters.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/kaui/account_children_controller.rb', line 18 def pagination searcher = lambda do |parent_account_id, offset, limit| Kaui::Account.find_children(parent_account_id, true, true, 'NONE', ) end data_extractor = lambda do |account_child, column| [ account_child.name, account_child.account_id, account_child.external_key, account_child.account_balance, account_child.city, account_child.country ][column] end formatter = lambda do |account_child| [ view_context.link_to(account_child.account_id, account_path(account_child.account_id)), account_child.external_key, view_context.humanized_money_with_symbol(account_child.balance_to_money), ] end paginate searcher, data_extractor, formatter end |