Class: Protege::AgentsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Protege::AgentsController
- Defined in:
- app/controllers/protege/agents_controller.rb
Overview
Manages agent records — listing, creating, viewing, editing, and permanent deletion.
An agent is the identity behind an inbox; the controller surfaces the full CRUD the dashboard
needs. destroy is the hard, irreversible removal (cascading all the agent's data); the
reversible, history-preserving alternative is archiving — see ArchivesController.
Instance Method Summary collapse
-
#create ⇒ void
Create an agent from the form's split email fields.
-
#destroy ⇒ void
Permanently delete an agent and everything it owns.
-
#edit ⇒ void
Render the form for editing an agent.
-
#index ⇒ void
List every agent.
-
#new ⇒ void
Render the form for creating an agent.
-
#show ⇒ void
Show a single agent.
-
#update ⇒ void
Update an existing agent.
Instance Method Details
#create ⇒ void
This method returns an undefined value.
Create an agent from the form's split email fields. Serves POST /agents.
On failure, re-render the form with validation errors.
41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/protege/agents_controller.rb', line 41 def create @agent = Agent.new(create_params) if @agent.save redirect_to agent_path(@agent), notice: 'Agent created.' else render :new, status: :unprocessable_entity end end |
#destroy ⇒ void
This method returns an undefined value.
Permanently delete an agent and everything it owns. Serves DELETE /agents/:id.
This is the hard, irreversible removal (the reversible path is Archive — see ArchivesController):
the model cascades the agent's threads, messages, responsibilities, access rules, and tool-use
history. BroadcastableAgent removes its sidebar row.
71 72 73 74 75 |
# File 'app/controllers/protege/agents_controller.rb', line 71 def destroy @agent.destroy! redirect_to agents_path, notice: 'Agent deleted.' end |
#edit ⇒ void
This method returns an undefined value.
Render the form for editing an agent. Serves GET /agents/:id/edit.
34 |
# File 'app/controllers/protege/agents_controller.rb', line 34 def edit; end |
#index ⇒ void
This method returns an undefined value.
List every agent. Serves GET /agents.
15 16 17 |
# File 'app/controllers/protege/agents_controller.rb', line 15 def index @agents = Agent.all end |
#new ⇒ void
This method returns an undefined value.
Render the form for creating an agent. Serves GET /agents/new.
27 28 29 |
# File 'app/controllers/protege/agents_controller.rb', line 27 def new @agent = Agent.new end |
#show ⇒ void
This method returns an undefined value.
Show a single agent. Serves GET /agents/:id.
22 |
# File 'app/controllers/protege/agents_controller.rb', line 22 def show; end |
#update ⇒ void
This method returns an undefined value.
Update an existing agent. Serves PATCH /agents/:id.
On failure, re-render the edit form with validation errors.
56 57 58 59 60 61 62 |
# File 'app/controllers/protege/agents_controller.rb', line 56 def update if @agent.update(update_params) redirect_to agent_path(@agent), notice: 'Agent updated.' else render :edit, status: :unprocessable_entity end end |