Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在rails3中选择具有多个集合的标记?_Ruby On Rails_Ruby On Rails 3_Activerecord - Fatal编程技术网

Ruby on rails 在rails3中选择具有多个集合的标记?

Ruby on rails 在rails3中选择具有多个集合的标记?,ruby-on-rails,ruby-on-rails-3,activerecord,Ruby On Rails,Ruby On Rails 3,Activerecord,因此,我使用这个select标记拉取一组页面供用户选择: <%= f.select(:read_more, Page.all.collect{|page| [page.title, page.section.name.to_s+"/"+page.slug.to_s]}, {:include_blank => false}) %> false})%> 但我还想在同一个选择框中添加第二个集合bio's。有可能吗?求和就行了 Page.all.collect{|page| [pa

因此,我使用这个select标记拉取一组页面供用户选择:

<%= f.select(:read_more, Page.all.collect{|page| [page.title, page.section.name.to_s+"/"+page.slug.to_s]}, {:include_blank => false}) %>
false})%>
但我还想在同一个选择框中添加第二个集合bio's。有可能吗?

求和就行了

Page.all.collect{|page| [page.title, page.section.name.to_s+"/"+page.slug.to_s]} + Bio.all.collect{|bio| [bio.name, bio.age] }
所以

false})%>

这里有一些类似于您试图实现的目标 问题不在于如何在选择框中显示项目,而在于如何稍后在控制器中检索值

<%= f.select(:read_more, Page.all.collect{|page| [page.title, page.section.name.to_s+"/"+page.slug.to_s]} + Bio.all.collect{|bio| [bio.name, bio.age] }, {:include_blank => false}) %>