Rails 3.1.3
I have a model 'Airline', whose STRING column is 'company' only. Also, another model 'Plan' has an INTEGER column 'airline_id'.
I would like to show the 'company' name (string) in a template like
<% @plans.each do |plan| %> Airline: <%= @airlines.find(plan.airline_id).first.company %><br /> ... <% end %>
in the 'plans_controller.rb',
@plans = Plan.all @airlines = Airline.all
Obviously this does not work although no error appears. It shows 'Airline' all the same, where each plan should have a distinct airline company. Certainly the database stores the airline company names which correspond to the plans. The loop in the view template gives, however, the identical value.
Could anyone give some ideas that the template view shows distinct airline company corresponding to each plan?
Thanks.
soichi