私は2つのオブジェクト成分と起源を持っています。
各成分には起源があるので、私が持っている成分ではorigin_id
がビューに表示されます
<p>
<b>Name:</b>
<%= @ingredient.name %>
</p>
<p>
<b>Origin:</b>
<%= @ingredient.origin_id %>
</p>
IDではなくオリジン名を表示したい。
名前をディスプレイに表示するにはどうすればよいですか?
EDIT:クラスの成分は次のように宣言されています
class Ingredient < ActiveRecord::Base
has_and_belongs_to_many :recipes
belongs_to :origin
attr_accessible :name, :origin_id
end
クラスの起源
class Origin < ActiveRecord::Base
attr_accessible :name
end