Ruby on rails 在f.association中收集数据

Ruby on rails 在f.association中收集数据,ruby-on-rails,ruby-on-rails-4,simple-form,Ruby On Rails,Ruby On Rails 4,Simple Form,我有一个RoR应用程序,我从Ruby 1.9.3、Rails 3.2和Bootstrap 2中开始,使用简单的表单。在继续之前,我决定转向Ruby 2.0、Rails 4.0和Bootstrap 3。有一个移民问题让我感到困惑 在Rails 3.2版本中,这很好: <%= f.association :services, collection: @account.company.services, as: :check_boxes, label_method: :description %

我有一个RoR应用程序,我从Ruby 1.9.3、Rails 3.2和Bootstrap 2中开始,使用简单的表单。在继续之前,我决定转向Ruby 2.0、Rails 4.0和Bootstrap 3。有一个移民问题让我感到困惑

在Rails 3.2版本中,这很好:

<%= f.association :services, collection: @account.company.services, as: :check_boxes, label_method: :description %>
在Rails 4.0的世界中,它在收集数据时没有给我任何东西。在Rails 4.0中,这些都可以工作:

<%= f.association :services, as: :check_boxes %>
<%= f.association :services, collection: Service.all, as: :check_boxes, label_method: :description %>
<%= f.association :services, collection: Service.where(id: 1), as: :check_boxes, label_method: :description %>
在Rails控制台上,@account.company.services返回ActiveRecord::Associations::CollectionProxy[<…>]>而Service.all返回ActiveRecord::Relation[<…>]>

有人知道将我的选择放入f.association集合的正确格式吗

编辑:


它正在工作。我的一部分问题是使用了一个没有加入“服务”的“公司”记录。不过,我确实将其与其他问题联系了起来,这些问题都源于CollectionProxy替换了旧的数组或关系返回对象。我可以通过在集合中使用.to_a来修复其中的大部分问题。

您在Rails 4中使用的是哪个版本的SimpleForm?可能是相同的问题: