Initial
This commit is contained in:
50
app/controllers/solicitud_controller.rb
Executable file
50
app/controllers/solicitud_controller.rb
Executable file
@@ -0,0 +1,50 @@
|
||||
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
|
||||
Reference in New Issue
Block a user