I am trying to retrieve a column from another related table, and display that instead of the ID number thats associated in the index view pages.
Tables:
users: id, username, email
fillups: user_id, vehicle_id, mileage, fillup_date, cost, gallons
vehicles: make, model, color, vehicle_id
When viewing fillups/index you see a list of Fillups, which have the id # associated with each user and vehicle.. i want it to say the username, and make of the vehicle instead (this are columns in the tables). I got this similarly to work in create/edit but that was just showing ALL vehicles for a specific user..
I can’t find in the documentation how to do this, i know it deals specifically with the ORM. not sure though..
Screen capture of the index view page
Currently Vehicle ID pulls from the Fillups.vehicle_id column, it needs to be changed to pull from the Vehicles.vehicle_name column..

I answered my own question… by associating a
has_manyandbelongs_toin the models i was able to call thevehicle_namein the view.in my fillup model i added:
in my vehicle model i added:
in my view i then could call the vehicle name in the foreach loop like so:
I did the same thing for username in place of user_id