Ruby on rails Rails选择表单帮助程序不能很好地处理我的哈希

Ruby on rails Rails选择表单帮助程序不能很好地处理我的哈希,ruby-on-rails,forms,ruby-on-rails-4,form-helpers,Ruby On Rails,Forms,Ruby On Rails 4,Form Helpers,我想在编辑表单中更新事务对象的状态属性。状态应该是一个下拉列表,从中我可以选择一个与实际修补到对象的整数值相关的文本值 换句话说,我有一个变量如下所示: @statuscodes = [ { "Working" => 1 }, { "In progress" => 2 }, { "Cancelled: No response from borrower" => 3 }, { "Cancelled: No response from lender" => 4 }, { "

我想在编辑表单中更新
事务
对象的
状态
属性。状态应该是一个下拉列表,从中我可以选择一个与实际修补到对象的整数值相关的文本值

换句话说,我有一个变量如下所示:

@statuscodes = [
{ "Working" => 1 },
{ "In progress" => 2 },
{ "Cancelled: No response from borrower" => 3  },
{ "Cancelled: No response from lender" => 4 },
{ "Cancelled: Time period too long" => 5 },
...
]
<%= f.collection_select :status, @statuscodes[0], :last, :first, {include_blank: true} %>
在文档和其他一些SO帖子之后,我用我认为正确的语法尝试了
f.select
f.collection\u select
。显然不是,我已经打印了下面的每个错误。有没有想过我做错了什么

<%= f.select :transaction, :status, options_for_select(@statuscodes), {include_blank: true} %>
<!-- undefined method `merge' for #<ActiveSupport::SafeBuffer:0x007fd9da299300> -->

<%= f.collection_select :transaction, :status, @statuscodes, :last, :first, {include_blank: true} %>
<!-- undefined method `merge' for :first:Symbol -->

<%= f.select :transaction, :status, @statuscodes, {include_blank: true} %>
<!-- undefined method `merge' for #<Array:0x007fd9e1381b30> -->

应该是这样的:

@statuscodes = [
{ "Working" => 1 },
{ "In progress" => 2 },
{ "Cancelled: No response from borrower" => 3  },
{ "Cancelled: No response from lender" => 4 },
{ "Cancelled: Time period too long" => 5 },
...
]
<%= f.collection_select :status, @statuscodes[0], :last, :first, {include_blank: true} %>


请注意,第二个参数应该是
散列
对象数组
,可以调用第三个和第四个参数中提供的方法。

应该是
你能检查一下这篇文章吗每个人都是对的。。。我不需要
:事务
,而且我的
@statuscodes
声明不正确。我把它作为一个散列数组,因为我想我累了。。。而不是一个真正的散列!