I am new to rails and getting stuck a lot trying to develop my first app. I have a rails 3.2.2 application with the following tables (simplified):
Vehicle (has_many :checklists)
number:string
license_plate:string
Checklist (belongs_to :vehicle)
vehicle_id:integer
mileage:integer
I need to display a table listing every vehicle and mileage difference between two given dates like the following:
From: 2012/05/01
To:2012/06/01
Vehicle number License plate Mileage difference
000001 LIH576 453
000002 KUL763 158
000003 OSF473 631
I couldn’t figure out how to come up with the Mileage difference value. Any help would be greatly appreciated.
Thanks!
Corix
Well, you could subtract the mileage of
fromandtodates.Assuming the
todate is the most recent.