Class: Kiqr::Users::Settings::AccountsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/kiqr/users/settings/accounts_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/kiqr/users/settings/accounts_controller.rb', line 13

def create
  @account = Account.new()

  # Link the current user to the account as the owner
  @account.members.new(user: current_user, owner: true)

  if @account.save
    kiqr_flash_message :success, :account_created
    redirect_to dashboard_path(account_id: @account)
  else
    render :new, status: :unprocessable_content
  end
end

#indexObject



5
6
7
# File 'app/controllers/kiqr/users/settings/accounts_controller.rb', line 5

def index
  @memberships = current_user.members.includes(:account).references(:account)
end

#newObject



9
10
11
# File 'app/controllers/kiqr/users/settings/accounts_controller.rb', line 9

def new
  @account = Account.new
end