Pruebas
This commit is contained in:
19
app/controllers/ruta_controller.rb
Normal file
19
app/controllers/ruta_controller.rb
Normal file
@ -0,0 +1,19 @@
|
||||
class RutaController < ApplicationController
|
||||
def get
|
||||
Ruta.find(params[:ruta])
|
||||
end
|
||||
|
||||
def add
|
||||
@ruta = Ruta.create
|
||||
for data_viaje in params[:viajes] do
|
||||
viaje = @ruta.viajes.create(direccion_partida: data_viaje[:direccion_partida], direccion_llegada: data_viaje[:direccion_llegada], kms: data_viaje[:kms])
|
||||
for data_entrega in data_viaje[:entregas] do
|
||||
viaje.entregas.create(nombre_recibe: data_entrega[:nombre_recibe], carga: data_entrega[:carga])
|
||||
end
|
||||
for data_retiro in data_viaje[:retiros] do
|
||||
viaje.retiros.create(nombre_entrega: data_retiro[:nombre_recibe], carga: data_retiro[:carga])
|
||||
end
|
||||
end
|
||||
@ruta
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user