51 lines
1.3 KiB
Ruby
Executable File
51 lines
1.3 KiB
Ruby
Executable File
class SolicitudController < ApplicationController
|
|
before_action :set_solicitud, only: [:show, :update, :destroy]
|
|
|
|
# GET /solicitud
|
|
def index
|
|
@solicitudes = Solicitud.all
|
|
render :json => @solicitudes
|
|
end
|
|
|
|
# GET /solicitud/1
|
|
def show
|
|
render :json => @solicitud
|
|
end
|
|
|
|
# POST /solicitud
|
|
def create
|
|
@solicitud = Solicitud.new(solicitud_params)
|
|
|
|
if @solicitud.save
|
|
render json: @solicitud, status: :created, location: @solicitud
|
|
else
|
|
render json: @solicitud.errors, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
# PATCH/PUT /solicitud/1
|
|
def update
|
|
if @solicitud.update(solicitud_params)
|
|
render json: @solicitud
|
|
else
|
|
render json: @solicitud.errors, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
# DELETE /solicitud/1
|
|
def destroy
|
|
@solicitud.destroy
|
|
end
|
|
|
|
private
|
|
# Use callbacks to share common setup or constraints between actions.
|
|
def set_solicitud
|
|
@solicitud = Solicitud.find(params[:id])
|
|
end
|
|
|
|
# Only allow a trusted parameter "white list" through.
|
|
def solicitud_params
|
|
params.permit(:nombre, :email, :ciudad, :estado, :direccion, :detalles, :presupuesto, :tiempo_de_entrega, :telefono, :contacto_de_preferencia_id, :categoria_id, :status_id, :notas, :verificado)
|
|
end
|
|
end
|