Class: Logistics::Core::AddendumsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/logistics/core/addendums_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /addendums POST /addendums.json



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/logistics/core/addendums_controller.rb', line 15

def create
  @addendum = Addendum.new(addendum_params)

  if @addendum.valid?
    service_increment = ServiceIncrement.find(params[:service_increment_id])
    addendum = service_increment.addendums << @addendum
    @response = {:success => true, :message => 'Addition created successfully', :data => addendum}
    render json: @response
  else
    @response = {:success => false, :message => 'Error saving addition', :data => []}
    render json: @response
  end
end

#get_allObject



29
30
31
32
33
# File 'app/controllers/logistics/core/addendums_controller.rb', line 29

def get_all
  @addendums = Addendum.all
  @response = {:success => true, :message =>'', :data =>@addendums}
  render json: @response
end

#indexObject

GET /addendums GET /addendums.json



7
8
9
10
11
# File 'app/controllers/logistics/core/addendums_controller.rb', line 7

def index
  @addendums = Addendum.where('service_increment_id' => params[:service_increment_id])
  @response = {:success => true, :message => '', :data => @addendums}
  render json: @response
end