プラットフォームモデルに接続されたCategoriesという単純なモデルを作成しました。
class Platform < ActiveRecord::Base
attr_accessible :name, :url, :country, :categories
belongs_to :category
end
と
class Category < ActiveRecord::Base
attr_accessible :name
has_many :platforms
end
また、新しいプラットフォームを作成するためのフォームもあります。
<%= simple_form_for(@platform) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :name %>
<%= f.input :url %>
<%= f.input :country %>
<%= f.label :category %>
<%= f.collection_select(:category_id, @categories, :id, :name, :include_blank => "Please select") %>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>
残念ながら、モデルカテゴリは新しいため、ドロップダウンには現在「選択してください」という値が1つしかありません。できればモデルを介して、この選択に新しい値を追加するにはどうすればよいですか?