【发布时间】:2013-10-10 20:47:08
【问题描述】:
我有以下哈希数组,我需要解析所有不为空的电子邮件:
[{:id=>"something", :first_name=>"First", :last_name=>"Name", :name=>"First Name", :email=>"first_name@gmail.com", :gender=>nil, :birthday=>nil, :profile_picture=>nil, :relation=>nil},
{...},
{}]
我正在尝试这样做:
- @contacts[0].each_with_index do |c, i|
- unless c[:email].blank?
%tr
%td= c[:email]
%td= check_box_tag "email_to[]", c[:email], true
但我收到错误:
An ActionView::Template::Error occurred in users#parse_data:
no implicit conversion of Symbol into Integer
怎么做才对?
【问题讨论】:
-
在将结果传递给视图之前,我更希望看到编写的代码,以便您在控制器中使用
reject或select适当的数组条目。 -
我同意@theTinMan。修复联系人以使其正确,而不是在视图中进行调整,这很混乱。
标签: ruby-on-rails ruby arrays parsing hash