mirror of
https://github.com/czhu12/canine.git
synced 2025-12-21 10:49:49 -06:00
26 lines
497 B
Ruby
26 lines
497 B
Ruby
class AccountsController < ApplicationController
|
|
def switch
|
|
@account = current_user.accounts.friendly.find(params[:id])
|
|
session[:account_id] = @account.id
|
|
redirect_to root_path
|
|
end
|
|
|
|
def show
|
|
end
|
|
|
|
def create
|
|
account = current_user.accounts.create!(
|
|
name: account_params[:name],
|
|
owner: current_user
|
|
)
|
|
session[:account_id] = account.id
|
|
redirect_to root_path
|
|
end
|
|
|
|
private
|
|
|
|
def account_params
|
|
params.require(:account).permit(:name)
|
|
end
|
|
end
|