Class: SupplejackApi::PartnersController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/supplejack_api/partners_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
# File 'app/controllers/supplejack_api/partners_controller.rb', line 13

def create
  if params[:partner][:_id].present?
    @partner = Partner.find_or_initialize_by(_id: params[:partner][:_id])
    @partner.update_attributes(params[:partner])
  else
    @partner = Partner.create(params[:partner])
  end
  render json: @partner
end

#indexObject



28
29
30
31
# File 'app/controllers/supplejack_api/partners_controller.rb', line 28

def index
  @partners = Partner.all
  render json: @partners
end

#showObject



23
24
25
26
# File 'app/controllers/supplejack_api/partners_controller.rb', line 23

def show
  @partner = Partner.find params[:id]
  render json: @partner
end

#updateObject



33
34
35
36
37
# File 'app/controllers/supplejack_api/partners_controller.rb', line 33

def update
  @partner = Partner.find(params[:id])
  @partner.update_attributes(params[:partner])
  render json: @partner
end