Correccion de nombre ruta y se agregan metodos
This commit is contained in:
16
app/models/ruta.rb
Normal file
16
app/models/ruta.rb
Normal 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
|
Reference in New Issue
Block a user