Correccion de nombre ruta y se agregan metodos

This commit is contained in:
2024-09-11 20:58:38 -03:00
parent 8c63022011
commit 3cefdd8f38
2 changed files with 23 additions and 0 deletions

16
app/models/ruta.rb Normal file
View File

@ -0,0 +1,16 @@
class Ruta < ApplicationRecord
def direccion_inicio
@viajes.first.direccion_partida
end
def direccion_final
@viajes.last.direccion_llegada
end
def kms_total
@viajes.reduce(0) do |sum, viaje|
sum += viaje.kms
sum
end
end
end