Class: Mks::Rent::RequestItemsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/mks/rent/request_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/request_items_controller.rb', line 15

def create
  @request_item = RequestItem.new(request_item_params)

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

#destroyObject



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

def destroy
  @request_item.destroy
end

#indexObject



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

def index
  request_items = RequestItem.all
  render json: request_items
end

#showObject



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

def show
  render json: @request_item
end

#updateObject



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

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