Class: Mks::Rent::OfferItemsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/mks/rent/offer_items_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
# File 'app/controllers/mks/rent/offer_items_controller.rb', line 15

def create
  @offer_item = OfferItem.new(offer_item_params)

  if @offer_item.save
    render json: @offer_item, status: :created, location: @offer_item
  else
    render json: @offer_item.errors, status: :unprocessable_entity
  end
end

#destroyObject



33
34
35
# File 'app/controllers/mks/rent/offer_items_controller.rb', line 33

def destroy
  @offer_item.destroy
end

#indexObject



6
7
8
9
# File 'app/controllers/mks/rent/offer_items_controller.rb', line 6

def index
  offer_items = Mks::Common::MethodResponse(OfferItem.all)
  render json: offer_items
end

#showObject



11
12
13
# File 'app/controllers/mks/rent/offer_items_controller.rb', line 11

def show
  render json: @offer_item
end

#updateObject



25
26
27
28
29
30
31
# File 'app/controllers/mks/rent/offer_items_controller.rb', line 25

def update
  if @offer_item.update(offer_item_params)
    render json: @offer_item
  else
    render json: @offer_item.errors, status: :unprocessable_entity
  end
end