次の関連付けを持つ製品モデルとカテゴリモデルの 2 つのモデルがあります。
class Product < ActiveRecord::Base
belongs_to :category
validates :title, presence: true
end
class Category < ActiveRecord::Base
attr_accessible :name
has_many :products
end
simple_form を使用して新しい製品を作成しようとすると、category_id フィールドに、カテゴリの ID ではなく、カテゴリの名前が必要です。
<%= simple_form_for @product do |f| %>
<%= f.input :title %>
<%= f.input :description %>
<%= f.input :price %>
<%= f.input :category_id %>
<%= f.button :submit %>
<% end %>
どうすればいいですか?