Class: RcrewAI::Rails::AgentsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @agent = @crew ? @crew.agents.build(agent_params) : Agent.new(agent_params)
  
  if @agent.save
    redirect_to @agent, notice: 'Agent was successfully created.'
  else
    render :new
  end
end

#destroyObject



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

def destroy
  crew = @agent.crew
  @agent.destroy
  redirect_to crew ? crew : agents_url, notice: 'Agent was successfully deleted.'
end

#editObject



29
30
# File 'app/controllers/rcrewai/rails/agents_controller.rb', line 29

def edit
end

#indexObject



7
8
9
# File 'app/controllers/rcrewai/rails/agents_controller.rb', line 7

def index
  @agents = @crew ? @crew.agents : Agent.includes(:crew).all
end

#newObject



15
16
17
# File 'app/controllers/rcrewai/rails/agents_controller.rb', line 15

def new
  @agent = @crew ? @crew.agents.build : Agent.new
end

#showObject



11
12
13
# File 'app/controllers/rcrewai/rails/agents_controller.rb', line 11

def show
  @tools = @agent.tools
end

#updateObject



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

def update
  if @agent.update(agent_params)
    redirect_to @agent, notice: 'Agent was successfully updated.'
  else
    render :edit
  end
end