简体   繁体   中英

Getting the contents of a hash

{"test_url"=>"http://test.com/123.jpg"} 

is my output from

<% @results.each do |t| %>
    <%= t.image.extract!("test_url") %>
<% end %>

How can i just get the contents of test_url? so http://test.com/123.jpg

#extract! always deletes and returns the key/value pairs for the given key from the Hash.

To delete and only return the value:

<%= t.image.delete("test_url") %>

or, if you just want to get the value:

<%= t.image["test_url"] %>
<% @results.each do |t| %>
    <%= t.image["test_url"] %>
<% end %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM