Class: Iugu::AccountUsersController
- Inherits:
-
AccountSettingsController
- Object
- AccountSettingsController
- Iugu::AccountUsersController
- Defined in:
- app/controllers/iugu/account_users_controller.rb
Instance Method Summary collapse
- #cancel_destruction ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #transfer_ownership ⇒ Object
- #view ⇒ Object
Instance Method Details
#cancel_destruction ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/iugu/account_users_controller.rb', line 42 def cancel_destruction if @account_user = AccountUser.find_by_account_id_and_user_id(params[:account_id], params[:user_id]) @account = Account.find(params[:account_id]) @account_user.cancel_destruction redirect_to account_users_index_path(params[:account_id]), :notice => I18n.t("iugu.account_user_destruction_undone") else raise ActionController::RoutingError.new('Not Found') end end |
#destroy ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/iugu/account_users_controller.rb', line 31 def destroy if @account_user = AccountUser.find_by_account_id_and_user_id(params[:account_id], params[:user_id]) @account = Account.find(params[:account_id]) else raise ActionController::RoutingError.new('Not Found') end raise ActionController::RoutingError.new('Access Denied') if @account_user.user.id == current_user.id || @account_user.is?(:owner) @account_user.destroy redirect_to account_users_index_path(params[:account_id]), :notice => I18n.t("iugu.account_user_destruction_in") + @account_user.destruction_job.run_at.to_s end |
#index ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'app/controllers/iugu/account_users_controller.rb', line 5 def index if IuguSDK::enable_multiple_users_per_account @account = Account.find(params[:account_id]) @account_users = @account.account_users render 'iugu/account_users/index' else raise ActionController::RoutingError.new("Not found") end end |
#transfer_ownership ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/iugu/account_users_controller.rb', line 20 def transfer_ownership if @account_user = AccountUser.find_by_account_id_and_user_id(params[:account_id], params[:user_id]) @account = Account.find(params[:account_id]) else raise ActionController::RoutingError.new('Not Found') end raise ActionController::RoutingError.new('Access Denied') if @account_user.user.id == current_user.id || @account_user.is?(:owner) @account.transfer_ownership @account_user.user redirect_to account_users_index_path(params[:account_id]), :notice => I18n.t("iugu.account_user_make_owner") end |
#view ⇒ Object
15 16 17 18 |
# File 'app/controllers/iugu/account_users_controller.rb', line 15 def view @account_user = AccountUser.find_by_account_id_and_user_id(params[:account_id], params[:user_id]) render 'iugu/account_users/view' end |