Class: Aven::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Includes:
ApplicationHelper
Defined in:
app/controllers/aven/application_controller.rb

Instance Method Summary collapse

Methods included from ApplicationHelper

#aven_importmap_tags, #view_component

Instance Method Details

#current_workspaceObject

Get the current workspace from session



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/aven/application_controller.rb', line 8

def current_workspace
  return @current_workspace if defined?(@current_workspace)

  @current_workspace = if session[:workspace_id].present? && current_user
    current_user.workspaces.find_by(id: session[:workspace_id])
  elsif current_user
    # Auto-select first workspace if none selected
    workspace = current_user.workspaces.first
    session[:workspace_id] = workspace&.id
    workspace
  end
end

#current_workspace=(workspace) ⇒ Object

Set the current workspace



22
23
24
25
# File 'app/controllers/aven/application_controller.rb', line 22

def current_workspace=(workspace)
  @current_workspace = workspace
  session[:workspace_id] = workspace&.id
end