Displaying attribute from related table with a collection_select

I have two tables: Area, AreaType

Area belongs_to :area_type
AreaType has_many :areas

In my view, I’d like to select from a list of Areas, however, instead
of using the :area_type_id attribute, I would like to use the
associated area_type names. Here’s what it looks like now:

<%= f.collection_select(:area_id, Area.where(:subject_id =>
@search.subject_id), :id, :area_type_id, {:include_blank => true} ) %>

What I want is:
<%= f.collection_select(:area_id, Area.where(:subject_id =>
@search.subject_id), :id, area.area_type.name, {:include_blank =>
true} ) %>

Anyone know how I would go about creating the area.area_type.name
“symbol” to user here?

Thanks in advance!

Well that was easy! After a little trial and error, I created a new
method in the area.rb and used the name of that method in the
collection select :slight_smile: Cheers