Class: RcrewAI::Rails::CrewsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rcrewai/rails/crews_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/rcrewai/rails/crews_controller.rb', line 20

def create
  @crew = Crew.new(crew_params)
  
  if @crew.save
    redirect_to @crew, notice: 'Crew was successfully created.'
  else
    render :new
  end
end

#destroyObject



41
42
43
44
# File 'app/controllers/rcrewai/rails/crews_controller.rb', line 41

def destroy
  @crew.destroy
  redirect_to crews_url, notice: 'Crew was successfully destroyed.'
end

#editObject



30
31
# File 'app/controllers/rcrewai/rails/crews_controller.rb', line 30

def edit
end

#executeObject



46
47
48
49
50
51
# File 'app/controllers/rcrewai/rails/crews_controller.rb', line 46

def execute
  inputs = params[:inputs] || {}
  execution = @crew.execute_async(inputs)
  
  redirect_to execution_path(execution), notice: 'Crew execution started.'
end

#indexObject



6
7
8
# File 'app/controllers/rcrewai/rails/crews_controller.rb', line 6

def index
  @crews = Crew.includes(:agents, :tasks).all
end

#newObject



16
17
18
# File 'app/controllers/rcrewai/rails/crews_controller.rb', line 16

def new
  @crew = Crew.new
end

#showObject



10
11
12
13
14
# File 'app/controllers/rcrewai/rails/crews_controller.rb', line 10

def show
  @recent_executions = @crew.executions.recent.limit(10)
  @agents = @crew.agents
  @tasks = @crew.tasks.ordered
end

#updateObject



33
34
35
36
37
38
39
# File 'app/controllers/rcrewai/rails/crews_controller.rb', line 33

def update
  if @crew.update(crew_params)
    redirect_to @crew, notice: 'Crew was successfully updated.'
  else
    render :edit
  end
end