Class: AgentsController

Inherits:
AdminController show all
Defined in:
app/controllers/agents_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

post /agents



11
12
13
14
15
16
17
18
# File 'app/controllers/agents_controller.rb', line 11

def create
  @entity = Agent.new entity_parameters
  if @entity.save
    form_processed_ok(admin_agent_path(id: @entity.id))
  else
    form_processed_with_error(:new)
  end
end

#destroyObject

delete /agents/:id



38
39
40
41
42
43
# File 'app/controllers/agents_controller.rb', line 38

def destroy
  if @entity.update! deleted: true
    flash[:notice] = t('agents.destroy.success')
  end
  redirect_to admin_agents_path
end

#editObject

get /agents/:id/edit



25
26
# File 'app/controllers/agents_controller.rb', line 25

def edit
end

#newObject

get /agents/new



6
7
8
# File 'app/controllers/agents_controller.rb', line 6

def new
  @entity = Agent.new
end

#showObject

get /agents/:id



21
22
# File 'app/controllers/agents_controller.rb', line 21

def show
end

#updateObject

patch /agents/:id



29
30
31
32
33
34
35
# File 'app/controllers/agents_controller.rb', line 29

def update
  if @entity.update entity_parameters
    form_processed_ok(admin_agent_path(id: @entity.id))
  else
    form_processed_with_error(:edit)
  end
end