【发布时间】:2014-03-18 19:40:15
【问题描述】:
我的错误列表中出现了这个:
@error_messages = {
:password=>["can't be blank", "Password is required."],
:"addresses.firstname"=>["can't be blank","Firstname is required."],
:"addresses.city"=>["can't be blank", "city is required."]
}
在这里,我想从该哈希中删除“不能为空”的值,以便获得我包含的验证错误消息。
是否可以从上面的哈希列表中删除“不能为空”的值,我会在结果中得到这个:
@error_messages = {
:password=>["Password is required."],
:"addresses.firstname"=>["Firstname is required."],
:"addresses.city"=>["city is required."]
}
如何从哈希列表中删除特定值(想要删除特定值而不是完整的键值对)。
【问题讨论】: