Class: Logistics::Core::AgentsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Logistics::Core::AgentsController
- Defined in:
- app/controllers/logistics/core/agents_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/logistics/core/agents_controller.rb', line 18 def create @agent = Logistics::Core::Agent.new(agent_params) if @agent.valid? @agent.save @response = Mks::Common::MethodResponse.new(true, 'Agent saved successfully !',nil,nil,nil); render json: @response else errors = Mks::Common::Util. @agent, 'Agent' @response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) render json: @response end end |
#index ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/logistics/core/agents_controller.rb', line 6 def index @agents = Logistics::Core::Agent.all agents_array =[] @agents.each { |agent| agents_array.push({:id => agent.id, :name => agent.name, :email => agent.email, :contact_telephone => agent.contact_telephone }) } @response = Mks::Common::MethodResponse.new(true, nil, agents_array, nil, nil) render json: @response end |
#update ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/logistics/core/agents_controller.rb', line 31 def update if @agent.update_attributes(agent_params) @agent.save @response = Mks::Common::MethodResponse.new(true, 'Agent updated successfully !', nil, nil, nil) render json: @response else errors = Mks::Common::Util. @agent, 'Agent' @response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) render json: @response end end |