Class: RcrewAI::Rails::AgentsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RcrewAI::Rails::AgentsController
- Defined in:
- app/controllers/rcrewai/rails/agents_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
29 30 |
# File 'app/controllers/rcrewai/rails/agents_controller.rb', line 29 def edit end |
#index ⇒ Object
7 8 9 |
# File 'app/controllers/rcrewai/rails/agents_controller.rb', line 7 def index @agents = @crew ? @crew.agents : Agent.includes(:crew).all end |
#new ⇒ Object
15 16 17 |
# File 'app/controllers/rcrewai/rails/agents_controller.rb', line 15 def new @agent = @crew ? @crew.agents.build : Agent.new end |
#show ⇒ Object
11 12 13 |
# File 'app/controllers/rcrewai/rails/agents_controller.rb', line 11 def show @tools = @agent.tools end |
#update ⇒ Object
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 |