2014-02-21 2 views
1

해시 배열을 루비 다른 해시를 추가 할 수 없습니다가 나는 mongoid 객체를 가지고

개체 @tran@tran[:translations]

result에서 해시의 배열을 가지고

@tran = Translations.where({:_id => params[:id]})[0] 

내가 노력

다른 해시 가산기 result ~ @tran[:translations]

@tran[:translations] << result 

@tran[:translations]의 값은 [{*current value of result*}]으로 변경되고 추가되지 않습니다.

여기에 근본적으로 잘못된 것이 있습니까? 내가 뭔가 잘 작동

@tran[:translations] = @tran[:translations] + [result]

대신

@tran[:translations] << result

를 사용한 경우

+0

'p @tran [: translations]'를 보여줄 수 있습니까? –

+0

'@tran [: translations'의 값은''{{ "value": "hello3", "rating": 100, "rated": 0}]' –

+2

내 irb에서 검사했는데 이상한 점은 없었습니다. 당신은 .. –

답변

1

이 밝혀졌습니다.