我可以在以这种方式创建的表单中选择一组值;
@counties = district.counties.map{|f| [f.name, f.id]}
但是,我希望添加值;
["Please select Sub-County", " "]
我试过这个没有成功,
def update_counties
district = District.find(params[:district_id])
@counties = {} << ["Please select County", " "] << district.counties.map{|f| [f.name, f.id]}
@sub_counties = {} << ["Please select Sub-County", " "] << district.counties.first.sub_counties.map{|f| [f.name, f.id]}
respond_to do |format|
format.js { }
end
end
协助?请!
答案 0 :(得分:0)
@counties = [["Please select sub-county", ""]]
@counties += district.counties.map{|f| [f.name, f.id]}