我有一个表格;
<%= form_for @boats do |f| %>
<%= f.collection_select(:brand, :brand_id, @brands, :id, :name, {:prompt => "Select a Brand"}, {:id => 'brands_select'}) %>
<%= f.collection_select(:year, :year_id, @years, :id, :name, {:prompt => "Select a Year"}, {:id => 'years_select'}) %>
<%= f.collection_select(:model, :model_id, @models, :id, :name, {:prompt => "Select a Model"}, {:id => 'models_select'}) %>
<%= f.submit "Create my account" %>
<% end %>
并有控制器#index;
def index
@boats = Boat.new
@brands = Brand.all
@years = Year.all
@models = Model.all
end
但这里的问题是,当我运行代码时,它给出了一个错误;
所以我不确定该怎么做。基本上,数据来自数据库,我想将它们保存到列名是品牌、年份和型号的 Boat 数据库中。