Guest User

Untitled

a guest
May 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. w/merb:
  2.  
  3. (rdb:1) blah = {}
  4. {}
  5. (rdb:1) images = [{:src => '1', :href => '1' }, {:src => '2', :href => '2' }]
  6. [{:href=>"1", :src=>"1"}, {:href=>"2", :src=>"2"}]
  7. (rdb:1) blah[:images] = images
  8. [{:href=>"1", :src=>"1"}, {:href=>"2", :src=>"2"}]
  9. (rdb:1) blah.to_json
  10. TypeError Exception: wrong argument type Hash (expected Data)
  11.  
  12.  
  13. w/irb:
  14. ruby: main
  15. >> blah = {}
  16. # => {}
  17.  
  18. ruby: main
  19. >> images = [{:src => '1', :href => '1' }, { :src => '2', :href => '2' }]
  20. # => [{:href=>"1", :src=>"1"}, {:href=>"2", :src=>"2"}]
  21.  
  22. ruby: main
  23. >> blah[:images] = images
  24. # => [{:href=>"1", :src=>"1"}, {:href=>"2", :src=>"2"}]
  25.  
  26. ruby: main
  27. >> blah.to_json
  28. # => "{\"images\":[{\"href\":\"1\",\"src\":\"1\"},{\"href\":\"2\",\"src\":\"2\"}]}"
Add Comment
Please, Sign In to add comment