Class: Iugu::AccountUsersController

Inherits:
AccountSettingsController
  • Object
show all
Defined in:
app/controllers/iugu/account_users_controller.rb

Instance Method Summary collapse

Instance Method Details

#cancel_destructionObject



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.(params[:account_id], params[:user_id])
    @account = Account.find(params[:account_id])
    @account_user.cancel_destruction
    redirect_to (params[:account_id]), :notice => I18n.t("iugu.account_user_destruction_undone")
  else
    raise ActionController::RoutingError.new('Not Found')
  end
end

#destroyObject

Raises:

  • (ActionController::RoutingError)


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.(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 (params[:account_id]), :notice => I18n.t("iugu.account_user_destruction_in") + @account_user.destruction_job.run_at.to_s
end

#indexObject



5
6
7
8
9
10
11
12
13
# File 'app/controllers/iugu/account_users_controller.rb', line 5

def index
  if IuguSDK::
    @account = Account.find(params[:account_id])
    @account_users = @account.
    render 'iugu/account_users/index'
  else
    raise ActionController::RoutingError.new("Not found")
  end
end

#transfer_ownershipObject

Raises:

  • (ActionController::RoutingError)


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.(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 (params[:account_id]), :notice => I18n.t("iugu.account_user_make_owner")
end

#viewObject



15
16
17
18
# File 'app/controllers/iugu/account_users_controller.rb', line 15

def view
  @account_user = AccountUser.(params[:account_id], params[:user_id])
  render 'iugu/account_users/view'
end