Class: Mks::Rent::OffersController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /offers



20
21
22
23
24
25
26
27
28
# File 'app/controllers/mks/rent/offers_controller.rb', line 20

def create
  @offer = Offer.new(offer_params)

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

#destroyObject

DELETE /offers/1



40
41
42
# File 'app/controllers/mks/rent/offers_controller.rb', line 40

def destroy
  @offer.destroy
end

#indexObject

GET /offers



8
9
10
11
12
# File 'app/controllers/mks/rent/offers_controller.rb', line 8

def index
  @offers = Offer.all

  render json: @offers
end

#showObject

GET /offers/1



15
16
17
# File 'app/controllers/mks/rent/offers_controller.rb', line 15

def show
  render json: @offer
end

#updateObject

PATCH/PUT /offers/1



31
32
33
34
35
36
37
# File 'app/controllers/mks/rent/offers_controller.rb', line 31

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