Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8150889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:11:50+00:00 2026-06-06T15:11:50+00:00

I am new to rails and getting stuck a lot trying to develop my

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:11:53+00:00Added an answer on June 6, 2026 at 3:11 pm

    Well, you could subtract the mileage of from and to dates.

    c1 = Checklist.where(:vehicle_id => 1, :check_date => FROM_DATE)
    c2 = Checklist.where(:vehicle_id => 1, :check_date => TO_DATE)
    
    difference = c2.mileage - c1.mileage
    

    Assuming the to date is the most recent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are getting close to releasing our new rails app and so far interest
I just created a new rails app in Rails 3.1.1, and my application layout
I'm a newbie Rails developer who is getting the following error when trying to
I'm trying to migrate my application from Rails 3.0.7 to Rails 3.1.3. I have
I'm getting a permission denied when attempting to create a new rails app -
I have a new rails app which needs to access data from a legacy
I'm pretty new to Rails and I'm stuck getting a named route working properly.
I'm stuck - I'm building an accounting app in rails, and have a model
I'm pretty new to rails, and I have some trouble getting the philosophy and
I'm new to rails and getting the following error: NameError in FriendshipsController#create uninitialized constant

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.