I would like to display the category name instead of the number (cat_id) from a belongs to the relations, I have machines and does, basically here is the code -
show.html.erb
<p id="notice"><%= notice %></p> <p> <b>Make:</b> <%= @car.make_id %> </p> <h2> <em><%= @car.model %> <%= @car.body_typw %> <%= @car.engine_size %> <%= @car.trim %></em> </h2> <p> <%= image_tag @car.image(:large) %> </p> <% @carimages.each do |carimage| %> <%= image_tag carimage.image(:thumb), :class => "imgsmall" %> <% end %> <p> <b>Transmission:</b> <%= @car.transmission %> </p> <p> <b>Fuel type:</b> <%= @car.fuel_type %> </p> <p> <b>Millage:</b> <%= @car.millage %> </p> <p> <b>Price:</b> <%= number_to_currency(@car.price) %> </p> <p> <%= raw @car.content %> </p>
So basically I want the name Make here: -
<p> <b>Make:</b> <%= @car.make_id %> </p>
cars_controller.rb
class CarsController < ApplicationController
this is connected using make table - id and car table - make_id
thanks
Robbie
source share